求助70pts

P1093 [NOIP2007 普及组] 奖学金

hanxiaofensheng @ 2024-09-07 22:32:57

#include<bits/stdc++.h>
using namespace std;
int n, a[301], b[301], c[301], ans1[301], ans2[301];
int main(){
    cin>> n;
    for(int i=1;i<=n;i++){
        cin>> a[i]>> b[i]>> c[i];
        ans1[i]=i;
        ans2[i]=a[i]+b[i]+c[i];
    } 
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++){
            if(ans2[i]<ans2[j]||(ans1[i]>ans1[j]&&ans2[i]==ans2[j])){
                swap(ans1[i],ans1[j]);
                swap(ans2[i],ans2[j]);
            } 
        }       
    for(int i=1;i<=5;i++) cout<<ans1[i]<<" "<<ans2[i]<<endl;
    return 0;
}

求求了帮帮忙呗,谁帮忙给他一关


by meifan666 @ 2024-09-07 22:34:36

@hanxiaofensheng 如果两个同学总分相同,再按语文成绩从高到低排序


by hanxiaofensheng @ 2024-09-07 22:35:29

@meifan666 谢谢,已关


|