90分求助
查看原帖
90分求助
524160
Lin_Master楼主2021/12/1 17:37
#include<bits/stdc++.h>
using namespace std;

struct Stu{
	string _name;
	int _s1;
	int _s2;
	int _s3;
	int _sRes;
}_myArray[1005];
int _num;

bool cmp(Stu,Stu);
void ParseIn(){
	
	cin>>_num;
	for(int i=0;i<_num;i++){
		cin>>_myArray[i]._name>>_myArray[i]._s1>>_myArray[i]._s2>>_myArray[i]._s3;
		_myArray[i]._sRes=_myArray[i]._s1+_myArray[i]._s2+_myArray[i]._s3;
	}
	
}
void Core(){
	
	sort(_myArray,_myArray+_num,cmp);
	
}
void CWriteOut(){
	
	cout<<_myArray[0]._name<<' '<<_myArray[0]._s1<<' '<<_myArray[0]._s2<<' '<<_myArray[0]._s3<<endl;
	
}
int main(){
	ParseIn();
	Core();
	CWriteOut();
	
	return 0;
} 
bool cmp(Stu a,Stu b){
	
	if(a._sRes>b._sRes){
		return 1;
	}
	return 0;
} 
2021/12/1 17:37
加载中...