首页 > 代码库 > PAT Basic Level 1004

PAT Basic Level 1004

 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