chenzhongmugu @ 2024-08-11 22:49:33
#include<bits/stdc++.h>
using namespace std;
struct info
{
char name[10];
int chi;
int mat;
int en;
};
int main()
{
struct info stu[1010];
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>stu[i].name>>stu[i].chi>>stu[i].mat>>stu[i].en;
}
int maxn=-1,index=-1;
for(int i=1;i<=n;i++)
{
int total=stu[i].chi+stu[i].mat+stu[i].en;
if(maxn<total) maxn=total,index=i;
}
cout<<stu[index].name<<" "<<stu[index].chi<<" "<<stu[index].mat<<" "<<stu[index].en;
return 0;
}
by are_you_sure @ 2024-08-11 23:21:26
@chenzhongmugu 定义变量时不用加struct
by are_you_sure @ 2024-08-11 23:22:48
#include<bits/stdc++.h>
using namespace std;
struct info
{
char name[10];
int chi;
int mat;
int en;
};
int main()
{
/*struct不用*/ info stu[1010];
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>stu[i].name>>stu[i].chi>>stu[i].mat>>stu[i].en;
}
int maxn=-1,index=-1;
for(int i=1;i<=n;i++)
{
int total=stu[i].chi+stu[i].mat+stu[i].en;
if(maxn<total) maxn=total,index=i;
}
cout<<stu[index].name<<" "<<stu[index].chi<<" "<<stu[index].mat<<" "<<stu[index].en;
return 0;
}