1004. 成绩排名

 1 /*
 2  * Main.c
 3  * 1004. 成绩排名
 4  *  Created on: 2014年8月28日
 5  *      Author: Boomkeeper
 6  ***********测试通过*********
 7  */
 8 
 9 #include <stdio.h>
10 
11 struct student {
12     char name[11];
13     char num[11];
14     int score;
15 };
16 
17 int main(void) {
18 
19     int n; //题目中的n
20     int i, j;
21     struct student stuMax, stuMin, temp;
22     stuMax.score = -1;
23     stuMin.score = 101;
24 
25     scanf("%d", &n);
26     getchar();
27 
28     for (i = 0; i < n; i++) {
29         scanf("%s %s %i", temp.name, temp.num, &temp.score);
30         getchar();
31 
32         if (stuMax.score < temp.score) {
33             for (j = 0; j < 11; j++) {
34                 stuMax.name[j] = temp.name[j];
35                 stuMax.num[j] = temp.num[j];
36             }
37             stuMax.score = temp.score;
38         }
39         if (stuMin.score > temp.score) {
40             for (j = 0; j < 11; j++) {
41                 stuMin.name[j] = temp.name[j];
42                 stuMin.num[j] = temp.num[j];
43             }
44             stuMin.score = temp.score;
45         }
46     }
47     printf("%s %s\n", stuMax.name, stuMax.num);
48     printf("%s %s\n", stuMin.name, stuMin.num);
49 
50     return 0;
51 }

 

题目链接:

http://pat.zju.edu.cn/contests/pat-b-practise/1004

参考:

http://www.cnblogs.com/shuanghong/archive/2013/04/16/3024998.html

 

posted @ 2014-08-28 10:35  Boomkeeper  Views(401)  Comments(2Edit  收藏  举报
最好的流量统计 网站流量计数器