#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
struct hhh{
string name;//名字
int y,m,d;//年,月,日
int b;//编号
}c[100001];
bool cmp(hhh x,hhh y){
if(x.y==y.y){//如果年份相同
if(x.m==y.m){//如果月份相同
if(x.d==y.d){//如果日期相同
return x.b<y.b;//用编号判断
}else
return x.d<y.d;
}else
return x.m<y.m;
}else
return x.y<y.y;
}
int main(){
int n;//n个人
cin>>n;
for(int i=1;i<=n;i++){
cin>>c[i].name>>c[i].y>>c[i].m>>c[i].d;//输入名字、出生年、月、日
c[i].b=i;//绑编号
}
sort(c+1,c+1+n,cmp);//排序
for(int i=1;i<=n;i++){
cout <<c[i].name<<endl;//输出
}
return 0;
}
是结构体有什么问题吗?
求助求助!QAQ