解题思路:
注意事项:
参考代码:
#include <iostream> #include <algorithm> using namespace std; struct st{ int sn,chinese, english, math, total; }; const int N = 1e3 + 10; st score[N]; bool cmp(st a, st b){ if (a.total == b.total){ if(a.chinese == b.chinese) return a.sn < b.sn; return a.chinese > b.chinese; } return a.total > b.total; } int main(){ int n; cin >> n; for(int i = 0; i < n; i ++) { score[i].sn = i + 1; cin >> score[i].chinese >> score[i].math >> score[i].english; score[i].total = score[i].chinese + score[i].math + score[i].english; } sort(score, score + n, cmp); for(int i = 0; i < 5; i ++){ cout << score[i].sn << ' ' << score[i].total<< endl; } return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:982 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:896 |
最小公倍数 (C语言代码)浏览:1086 |
1642题解浏览:778 |
1051(奇了怪了)浏览:739 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:727 |
时间转换 (C语言代码)浏览:685 |
C语言程序设计教程(第三版)课后习题12.3 (C语言代码)浏览:583 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:627 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:535 |