zysg @ 2024-10-08 22:26:58
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{ int num; int Chinese; int math; int English; int total; }s[305];
bool cmp(node a,node b) { if(a.total!=b.total) return a.total>b.total; if(a.Chinese!=b.Chinese) return a.Chinese>b.Chinese; return a.num>b.num; }
int main(){ int n; cin>>n; for(int i=1;i<=n;i++) { scanf("%d %d %d",&s[i].Chinese,&s[i].math,&s[i].English); s[i].num=i; s[i].total=s[i].Chinese+s[i].math+s[i].English; } sort(s+1,s+1+n,cmp); for(int i=1;i<=5;i++) { printf("%d %d\n",s[i].num,s[i].total); } return 0; }
by Lisuyang @ 2024-10-08 22:32:43
@zysg
注意:学号小的排前面
by zysg @ 2024-10-09 15:22:21
@Lisuyang 谢谢大佬!