请问这样的输出是怎么回事?

P5740 【深基7.例9】最厉害的学生

Wang_Junduo @ 2024-05-12 13:41:43

#include<bits/stdc++.h>
using namespace std;
int n;
struct stu
{
    string id;
    int c,m,e;
    int num=0;
}a[1001];
bool cmp(stu a,stu b)
{
    if(a.num!=b.num)
        a.num>b.num;
    else
        a.id<b.id;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].id>>a[i].c>>a[i].m>>a[i].e;
        a[i].num=a[i].c+a[i].m+a[i].e;
    }
    sort(a+1,a+n+1,cmp);
    cout<<a[1].id<<' '<<a[1].c<<' '<<a[1].m<<' '<<a[1].e<<endl;
    return 0;
}

by XuYueming @ 2024-05-12 14:04:21

@Wang_Junduo donny 说,return 呢?望给关注


by XuYueming @ 2024-05-12 14:51:05

@Wang_Junduo 说话!


by Wang_Junduo @ 2024-05-14 12:35:04

@XuYueming 哦,谢谢大佬


by Wang_Junduo @ 2024-05-14 12:35:49

@XuYueming 已关注


|