jkluio1 @ 2024-03-17 17:11:10
struct student {
char name[8];
int score[3];
int sum=0;
};
int main()
{
student s[1001];
int n = 0,max=0,maxidex=0;
cin >> n;
for(int i=0;i<n;i++)
{
cin >> s[i].name;
for (int j = 0; j < 3; j++)
{
cin >> s[i].score[j];
s[i].sum+= s[i].score[j];
}
if (s[i].sum > max)
{
max = s[i].sum;
maxidex = i;
}
}
cout << s[maxidex].name<<" ";
for (int i = 0; i < 3; i++)
cout << s[maxidex].score[i] << " ";
return 0;
}
by hoty2011 @ 2024-03-21 17:54:43
把结构体里的name数组开大一点就AC了。