80分求助
查看原帖
80分求助
615297
frankfan7707楼主2022/5/12 17:39

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

#include<bits/stdc++.h>
using namespace std;
struct student{
	string name;
	int chinese;
	int maths;
	int english;
	int score;
};
bool cmp(student a,student b){
	if(a.score==b.score)return a.name<b.name;
	else return a.score>b.score;
}
int n;
student s[10005];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i].name>>s[i].chinese>>s[i].maths>>s[i].english;
		s[i].score=s[i].chinese+s[i].maths+s[i].english;
	}
	sort(s,s+n,cmp);
	cout<<s[0].name<<" "<<s[0].chinese<<" "<<s[0].maths<<" "<<s[0].english;
} 
/*
*  ┏┓    ┏┓+ +
* ┏┛┻━━━━━━━┛┻┓ + +
* ┃      ┃
* ┃  ━    ┃ ++ + + +
*  ████  ━  ████+
*  ◥██◤ ◥██◤ +
* ┃   ┻   ┃
* ┃      ┃ + +
* ┗━┓   ┏━┛
*   ┃   ┃ + + + +Code is far away from  
*   ┃   ┃ + bug with the animal protecting
*   ┃    ┗━━━┓ 神兽保佑,代码无bug 
*   ┃      ┣┓
*    ┃      ┏┛
*     ┗┓┓┏━┳┓┏┛ + + + +
*    ┃┫┫ ┃┫┫
*    ┗┻┛ ┗┻┛+ + + +
*/

请忽视代码末尾请大佬们帮忙看看哪里出现了问题,感谢!

2022/5/12 17:39
加载中...