90分求助,第一个测试点没过
查看原帖
90分求助,第一个测试点没过
749815
2207bug楼主2024/3/30 17:30
#include<iostream>
#include<algorithm>
using namespace std;

struct Student{
    string name;
    int chinese;
    int math;
    int english;
};

bool cmp(const Student& s1, const Student& s2){
    if((s1.chinese+s1.math+s1.english) > (s2.chinese+s2.math+s2.english)){
    	return true;
	}else{
		return false;
	}
}

int n;
Student s[1000];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s[i].name >> s[i].chinese >> s[i].math >> s[i].english;
    }
    sort(s, s+n, cmp);
    cout << s[0].name << " " << s[0].chinese << " " << s[0].math << " " << s[0].english << endl;
    return 0;
}
2024/3/30 17:30
加载中...