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

1004. 成绩排名 (20)

时间:2015-09-06 21:37:34      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

#include <stdio.h>
#include <stdbool.h>

struct student {
    char name[10];
    int number[10];
    int score;
};

int main(void) {
    int n;
    scanf("%d",&n);
    struct student input[n];
    for(int i = 0; i<n; i++) {
        scanf("%s %s %d", input[i].name, input[i].number, &input[i].score);
    }
    int j = 0,max = input[0].score,min = input[0].score,maxdown = 0, mindown = 0;
    while (j != n){
        if (input[j].score>max) {
            max = input[j].score;
            maxdown = j;
        }
        if (input[j].score<min) {
            min = input[j].score;
            mindown = j;
        }
        j++;
    }
    printf("%s %s\n",input[maxdown].name, input[maxdown].number);
    printf("%s %s\n",input[mindown].name, input[mindown].number);
    return 0;
}

 

1004. 成绩排名 (20)

标签:

原文地址:http://www.cnblogs.com/sjdeak/p/4787048.html

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