虽然是结构体排序,但我不用!
2026-06-24 17:02:07
发布于:上海
1阅读
0回复
0点赞
#include<iostream>
#include <string>
using namespace std;
struct id{
string name;
int height,birthday;
}outerman;
bool check(id a,id b){
if(a.height<b.height)return false;
else if(a.height>b.height)return true;
if(a.birthday>b.birthday)return false;
return true;
}
int main(){
int n;cin>>n;id maxm={"???",-1,9999};//不存在的人
for(int i=1;i<=n;i++){
cin>>outerman.name>>outerman.height>>outerman.birthday;
if(!check(maxm,outerman))//最大值模拟 bubble sort 第一轮
maxm=outerman;
}
cout<<maxm.name<<" "<<maxm.height<<" "<<maxm.birthday;
}
//这是我个人的缩紧写法
愣着干嘛,点赞,好友,加关注!!!
这里空空如也






有帮助,赞一个