我爱刷题 • 2天前
using namespace std; int tot[500],mat[500],eng[500],chi[500],num[500]; int n; void sort(int * key){
for(int i=1;i<n;i++){
for(int j=n;j>i;j--){
if(key[j]>key[j-1]){
swap(tot[j],tot[j-1]);
swap(chi[j],chi[j-1]);
swap(mat[j],mat[j-1]);
swap(eng[j],eng[j-1]);
swap(num[j],num[j-1]);
}
}
}
} signed main(){
cin >> n;
for(int i=1;i<=n;i++){
cin >> chi[i] >> mat[i] >> eng[i];
tot[i]=chi[i]+mat[i]+eng[i];
num[i]=i;
}
sort(chi);
sort(tot);
for(int i=1;i<=5;i++){
cout << num[i] <<' '<< tot[i] << endl ;
}
return 0;
}
评论:
请先登录,才能进行评论