关注
2025-03-25 17:36:32
发布于:广东
30阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
struct ban{
string name;
long long sg,id;
};
bool cmp(ban a,ban b){
if(a.sg!=b.sg) return a.sg>b.sg;
else return a.id<b.id;
}
int main(){
int a;
cin>>a;
ban b[a];
for(int c=0;c<a;c++){
cin>>b[c].name>>b[c].sg>>b[c].id;
}
sort(b,b+a,cmp);
cout<<b[0].name<<' '<<b[0].sg<<' '<<b[0].id;
return 0;
}
全部评论 1
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
struct student{
string name;
int id;
double h;
}a[110];
bool cmp(student x,student y){
if(x.h!=y.h)return x.h>y.h;
else return x.id<y.id;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].name>>a[i].h>>a[i].id;
}
sort(a+1,a+n+1,cmp);
cout<<a[1].name<<" "<<a[1].h<<" "<<a[1].id;
return 0;
}2025-04-12 来自 四川
0
有帮助,赞一个