90分求助,谢谢各位神犇 c++
查看原帖
90分求助,谢谢各位神犇 c++
590571
_weishiqi66_楼主2022/4/15 13:26
#include<bits/stdc++.h>
#define maxx 114514
using namespace std;
struct jxj{
	long long num,f,f1;
}a[maxx];
bool cmp(jxj x,jxj y){
	if(x.f==y.f){
		return x.f1>y.f1;
	}
	else return x.f>y.f;
	
}
int main(){
	long long n,x,b,c;
	cin>>n;
	for(int i=1;i<=n;i++){
		a[i].num=i;
		cin>>x>>b>>c;
		a[i].f=x+b+c;
		a[i].f1=x;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=5;i++){
		cout<<a[i].num<<" "<<a[i].f;
		cout<<endl;
	}
	return 0;
}
2022/4/15 13:26
加载中...