#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=1000;
struct node{
char name[101];
int age;
int score;
bool operator < (const node &a)const{
if(a.score!=score)
return score<a.score;
int temp=strcmp(name,a.name);
if(temp!=0) return temp<0;
else return age<a.age;
}
}buf[N+5];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<n;i++)
{
cin>>buf[i].name>>buf[i].age>>buf[i].score;
}
sort(buf,buf+n);
for(int i=0;i<n;i++)
{
cout<<buf[i].name<<" "<<buf[i].age<<" "<<buf[i].score<<endl;
}
}
return 0;
}
结构体排序
最新推荐文章于 2021-11-04 11:29:02 发布