P1093奖学金

it2022-05-07  4

#include<bits/stdc++.h> using namespace std; struct cj{ int yw,sx,yy,xh; int zf; int sum(){ zf=yw+sx+yy; } }; cj ss[2000]; bool cmp(const cj &a,const cj &b){ if(a.zf>b.zf) return 1; if(a.zf<b.zf) return 0; if(a.yw>b.yw) return 1; if(a.yw<b.yw) return 0; if(a.xh>b.xh) return 0; if(a.xh<b.xh) return 1; } int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>ss[i].yw>>ss[i].sx>>ss[i].yy; ss[i].xh=i; ss[i].sum(); } sort (ss+1,ss+1+n,cmp); for(int i=1;i<=5;i++){ cout<<ss[i].xh<<" "<<ss[i].zf<<endl; } return 0; }

 ×输出只有五个

×sort中不要用.后缀;

转载于:https://www.cnblogs.com/luv-letters/p/8473916.html


最新回复(0)