90 求助

P1093 [NOIP2007 普及组] 奖学金

企图AC的蒟蒻 @ 2019-08-14 10:48:33

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
const int MAX=10001;
struct student
{
int num;
int chi,math,eng,total; 
}s[MAX];
int cmp(student a,student b)
{
if(a.total!=b.total)
  return a.total>b.total;
else
    if(a.chi!=b.chi)
     return a.chi>b.chi;
    else
     return a.num>b.num;
 } 
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
 {
    cin>>s[i].chi>>s[i].math>>s[i].eng;
    s[i].total=s[i].chi+s[i].math+s[i].eng;
    s[i].num=i;
 }
sort(s+1,s+1+n,cmp);
for(int i=1;i<=5;i++)
 cout<<s[i].num<<" "<<s[i].total<<endl;
return 0;
}

by    吾皇 @ 2019-08-14 10:51:51

学号小的排在前面..QAQ


by 喝脑白金的猪 @ 2019-08-14 10:57:28

瓦特


by    吾皇 @ 2019-08-14 10:58:36

emmm


by myj128128 @ 2019-08-14 11:03:01

同上,return a.num<b.num;


by myj128128 @ 2019-08-14 11:17:40

改过能AC,已试


|