3009 奖学金1
#include<bits/stdc++.h> using namespace std; struct node{ int yw,sx,yy,zf,id; //yw语文、sx数学、yy英语、zf总分、id顺序 }; node a[301]; bool comp(node a,node b) { //总分相同,顺序小优先,否则总分大优先 if(a.zf==b.zf){ return a.id<b.id; } else return a.zf>b.zf; } int main() { //1.定义变量 int n; //2.输入数据 cin>>n; for(int i=1;i<=n;i++) { cin>>a[i].yw>>a[i].sx>>a[i].yy; a[i].id = i; a[i].zf = a[i].yw+a[i].sx+a[i].yy; } sort(a+1,a+1+n,comp); for(int i=1;i<=5;i++) cout<<a[i].id<<" "<<a[i].zf<<endl; return 0; }