1004. 成绩排名 (20)

题目链接:https://www.patest.cn/contests/pat-b-practise/1004

 1 #include<stdio.h>     
 2 struct score{
 3     char n[11];
 4     char x[11];
 5     int  s;
 6 };
 7 int main()
 8 {
 9     struct score st[10000];
10     int N,a=0,b=0;
11     scanf("%d",&N);
12     for(int i=0;i<N;i++)scanf("%s %s %d",st[i].n,st[i].x,&st[i].s);
13     int min=st[0].s,max=st[0].s;
14     for(int i=1;i<N;i++)
15     {
16         if(min>st[i].s)
17         {
18             min=st[i].s;
19             a=i;
20         }
21         if(max<st[i].s)
22         {
23             max=st[i].s;
24             b=i;        
25         }
26     }
27     printf("%s %s\n",st[b].n,st[b].x);
28     printf("%s %s\n",st[a].n,st[a].x);
29     return 0;
30 }

 

posted @ 2018-01-16 16:56  爱你的笑  阅读(106)  评论(0编辑  收藏  举报