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

【PAT】B1004 成绩排名(20 分)

时间:2018-08-18 19:43:53      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:pac   std   \n   sizeof   ace   include   code   clu   scanf   

#include<cstdio>
#include<malloc.h>
#include<algorithm>
using namespace std;
typedef struct stu {
    char name[14];
    char number[14];
    int score;
}student;
bool cmp(student a,student b){
    return a.score>b.score;
}
int main() {
    int n;
    scanf("%d", &n);
    student *arr = (student *)malloc(sizeof(student)*n);
    for (int i = 0; i<n; i++) {
        scanf("%s %s %d", arr[i].name, arr[i].number, &(arr[i].score));
    }
    sort(arr,arr+n,cmp);
    printf("%s %s",arr[0].name,arr[0].number);
    printf("\n%s %s",arr[n-1].name,arr[n-1].number);
    return 0;
}

【PAT】B1004 成绩排名(20 分)

标签:pac   std   \n   sizeof   ace   include   code   clu   scanf   

原文地址:https://www.cnblogs.com/hebust/p/9498152.html

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