求助求助。。为什么前两个数据总是放不进去

P1093 [NOIP2007 普及组] 奖学金

seven7777 @ 2021-02-25 18:20:44

#include<bits/stdc++.h>
using namespace std;
int n;
struct data
{
    int total,chinese,id;
}a[310];
int cmp(data a,data b)
{
    return a.total>b.total;
    return a.chinese>b.chinese;
    return a.id<b.id;
}
int main()
{
    int math,english;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].chinese>>math>>english;
        a[i].total=a[i].chinese+math+english;
        a[i].id=i;
    }
    sort(a,a+n,cmp);
    for(int i=1;i<=5;i++)
    {
        cout<<a[i].id<<" "<<a[i].total<<endl; 
    }
    return 0;
}

by ScriptAccess @ 2021-02-25 18:40:39

sort(a+1,a+n+1,cmp);

下标是从1开始的


by seven7777 @ 2021-02-25 21:28:50

@ScriptAccess 解决了,谢谢


by seven7777 @ 2021-02-25 22:05:25

@ScriptAccess 但是还是只有50分,没有ac


|