PAT (Basic Level) Practice (中文)1004 成绩排名 (20 分)(20 分)_C语言实现

  • 题目地址
  • 题目解析:很简单,尤其是选用边读取边处理的解决办法
  • 我的代码:
#include<stdio.h>
#include<string.h>

int main()
{
    int n;
    scanf("%d\n",&n);

    int max=-1,min=101;
    char rec[3][2][11];
    for (int i = 0,tmp; i < n; i++)
    {
        scanf("%s %s %d",rec[0][0],rec[0][1],&tmp);
        if(tmp>max) strcpy(rec[1][0],rec[0][0]),strcpy(rec[1][1],rec[0][1]),max=tmp;
        if(tmp<min) strcpy(rec[2][0],rec[0][0]),strcpy(rec[2][1],rec[0][1]),min=tmp;
    }
    printf("%s %s\n%s %s",rec[1][0],rec[1][1],rec[2][0],rec[2][1]);

    return 0;
}

posted @ 2018-12-07 10:34  kingdalf  阅读(7)  评论(0)    收藏  举报  来源