码迷,mamicode.com
首页 > 其他好文 > 详细

PAT Basic Level 1004

时间:2016-10-19 01:34:09      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

 1 #include <stdio.h>
 2 struct student
 3 {
 4     int score;
 5     char nameChar[11];         
 6     char stunoChar[11];
 7 };
 8 int main ()
 9 {
10     struct student student[1000];
11     int count = 0; //测试数量
12     scanf("%d",&count);
13     int i = count-1;
14     while (i>=0)
15     {    
16     scanf("%s",&student[i].nameChar);
17     scanf("%s",&student[i].stunoChar);
18     scanf("%d",&student[i].score);
19     i--;
20     }
21     int max = student[0].score;
22     int min = student[0].score;
23     int maxNo = 0;
24     int minNo = 0;
25     i = count-1;
26     while (i >= 0)
27     {
28         if(student[i].score>max)
29         {
30             max = student[i].score;
31             maxNo = i;
32          } 
33          if(student[i].score<min)
34          {
35              min = student[i].score;
36              minNo = i;
37          }
38          i--;
39     }
40     printf("%s %s\n",student[maxNo].nameChar,student[maxNo].stunoChar);
41     printf("%s %s",student[minNo].nameChar,student[minNo].stunoChar);
42     return 0;
43     
44      
45  } 

 

PAT Basic Level 1004

标签:

原文地址:http://www.cnblogs.com/Ponytai1/p/5975432.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!