Kmeow @ 2024-02-22 22:38:46
#include <bits/stdc++.h>
using namespace std;
struct score{
string name;
int Chinese;
int Math;
int English;
int tot;
};
score sc[100];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>sc[i].name>>sc[i].Chinese>>sc[i].Math>>sc[i].English;
sc[i].tot=sc[i].Chinese+sc[i].English+sc[i].Math;
}
for(int i=1;i<n;i++)
for(int j=1;j<n;j++)
if(sc[j].tot<sc[j+1].tot)
swap(sc[j],sc[j+1]);
cout<<sc[1].name<<' '<<sc[1].Chinese<<' '<<sc[1].Math<<' '<<sc[1].English<<endl;
return 0;
}
拜托各位
by yueyan_WZF @ 2024-02-24 08:21:51
@Kmeow 数组开小了
by Kmeow @ 2024-02-27 20:50:56
谢谢大佬 (抱拳)!!