tangyiqi @ 2024-08-10 12:00:07
Help!
#include <bits/stdc++.h>
using namespace std;
int n;
struct pp{
int grade1,grade2,grade3,id,all;
}a[310];
bool cmp(pp a,pp b);
int main(){
scanf("%d",&n);
for(int i = 0;i<n;i++){
scanf("%d%d%d",&a[i].grade1,&a[i].grade2,&a[i].grade3);
a[i].all = a[i].grade1+a[i].grade2+a[i].grade3;
a[i].id = i+1;
}
sort(a,a+n,cmp);
for(int i = 0;i<5;i++){
printf("%d %d\n",a[i].id,a[i].all);
}
return 0;
}
bool cmp(pp a,pp b){
return a.all>b.all;
}
by NullPointerExpection @ 2024-08-10 12:28:33
@tangyiqi 需要考虑语文成绩相同的情况和学号相同的情况
by tangyiqi @ 2024-08-10 13:56:12
@NullPointerExpection
谢谢,我明白了