jiangsm @ 2024-09-17 14:06:19
#include <bits/stdc++.h>
using namespace std;
struct student
{
string nam;
int c;
int m;
int e;
};
student a[10005];
int main()
{
int n,mx=0;
cin>>n;
for(int i=0;i<=n-1;i++)
{
cin>>a[i].nam>>a[i].c>>a[i].m>>a[i].e;
if(a[i].c+a[i].m+a[i].e>mx)
{
mx=i;
}
}
cout<<a[mx].nam<<" "<<a[mx].c<<" "<<a[mx].m<<" "<<a[mx].e;
}
救救蒟蒻
by meifan666 @ 2024-09-17 14:25:18
@jiangsm 这里
if(a[i].c+a[i].m+a[i].e>mx)
{
mx=i;
}
mx记录了下标,你拿它当最大值?开两个变量
by jiangsm @ 2024-09-17 14:42:38
@meifan666 谢谢大佬