honey8848 @ 2024-01-28 19:47:00
#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct student
{
int score;
int x;
int y;
int z;
int number;
};
bool cmp(const student& a, const student& b)
{
if (a.score == b.score)
{
if (a.x == b.x)
{
if (a.y == b.y)
{
if (a.z == b.z)
{
return a.number < b.number;
}
else
{
return a.z > b.z;
}
}
else
{
return a.y > b.y;
}
}
else
{
return a.x > b.x;
}
}
else
{
return a.score > b.score;
}
}
int main()
{
struct student stu[300];
int n;
cin >> n;
int i;
for (i = 0; i < n; i++)
{
cin >> stu[i].x >> stu[i].y >> stu[i].z;
stu[i].score = stu[i].x + stu[i].y + stu[i].z;
stu[i].number = i + 1;
}
sort(stu, stu + n, cmp);
if (n > 5)
{
n = 5;
}
for (i = 0; i < n; i++)
{
cout << stu[i].number << ' ' << stu[i].score << endl;
}
return 0;
}
by 1612855242ytq @ 2024-01-28 19:58:59
只要求比较语文成绩吧,数学和英语是不管的
by honey8848 @ 2024-01-28 21:16:37
@1612855242ytq 已过,感谢
by tushanran @ 2024-01-29 11:59:57
return time error@honey8848