全wa 〇分求助

P5740 【深基7.例9】最厉害的学生

cmp里 ```cpp if(a.zong == b.zong){ return a.zong > b.zong; ``` 你很可以! AC代码: ```cpp #include <iostream> #include <algorithm> using namespace std; struct student{ string name; int m,e,c,pai, zong;//m:数学 e:英语 c:语文 pai:顺序 zong:总分 }; bool cmp(student a, student b){ if(a.zong != b.zong){ return a.zong > b.zong; } return a.pai < b.pai; } int main(){ int n; student stu[1010]; cin >>n; for(int i = 0; i < n; i++){ cin >> stu[i].name >> stu[i].c >> stu[i].m >> stu[i].e; stu[i].pai = i; stu[i].zong = stu[i].c + stu[i].m + stu[i].e; } sort(stu, stu + n, cmp); cout << stu[0].name << ' ' << stu[0].c << ' ' << stu[0].m << ' ' << stu[0].e; return 0; } //我把你的改了一下 ```
by 谁家小迷妹鸭 @ 2021-08-19 23:14:19


@[蒟蒻珂学家](/user/427617) 小哥哥你好粗心鸭
by 谁家小迷妹鸭 @ 2021-08-19 23:14:49


??救命
by 蒟蒻珂学家 @ 2021-08-19 23:47:22


@[蒟蒻珂学家](/user/427617) cmp里 ```cpp if(a.zong == b.zong){ return a.zong > b.zong; ``` 相当于return 0;
by Zvelig1205 @ 2021-08-20 10:36:27


|