满江红求助
查看原帖
满江红求助
1311900
Greeper楼主2024/7/28 15:55
#include<bits/stdc++.h>
using namespace std;
struct stu
{
    string name;
    int chi,mat,eng,tot;
};
stu a[1145];
void read(stu n)
{
    cin>>n.name>>n.chi>>n.mat>>n.eng;
    n.tot=n.chi+n.mat+n.eng;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        read(a[i]);
    }
    int maxtot=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i].tot>maxtot)
        {
            maxtot=a[i].tot;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i].tot==maxtot)
        {
        	cout<<a[i].name;
            printf(" %d %d %d",a[i].chi,a[i].mat,a[i].eng);
            return 0;
        }
    }
}
2024/7/28 15:55
加载中...