评选特等奖学金
Description
每到学年末,我院就开始评选特等奖学金。这项任务,工作量巨大,费时费力。但作为IT大佬的你,能否用自己的专业知识,帮助老师快速的选出特等奖学金得主呢?特等奖学金的要求如下:1此同学的素质分一定要是最高的。2如果素质分相同,则要选出绩点最高的。3如果还相同,则选择出没有挂科记录的。
Input
第一行为一个整数 n (1 <= n <= 100 ),表示学生的数量。 之后 n 行,每行三个整数,分别表示学号(12位整数),素质分(整型)、绩点(float类型,两位小数)和有无挂科记录(1表示有,0表示没有)
Output
占一行,特等奖学金得主的学号(题目保证只有一个输出)
Sample Input 1
4
123456780427 300 5.00 0
123456780429 300 4.90 0
123456780426 200 5.00 0
123456780430 300 5.00 1
Sample Output 1
123456780427
代码:
#include
#include
using namespace std;
struct student{
string id;//学号
int score1, flag;//素质分 挂科记录
double num;//绩点
}stu[120];
bool cmp(student a, student b){
if(a.score1 != b.score1) return a.score1 > b.score1;
if(a.num != b.num) return a.num > b.num;
if(a.flag != b.flag) return a.flag < b.flag;
}
int main(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> stu[i].id >> stu[i].score1 >> stu[i].num >> stu[i].flag;
}
sort(stu, stu + n, cmp);
cout << stu[0].id;
return 0;
}