本帖最后由 jhq999 于 2022-2-6 18:39 编辑 struct man {
char name[20];
union birthday
{
unsigned long long bday;
struct YMDHSTT
{
unsigned short hour;unsigned short day;unsigned short month;unsigned short year;
} ymdh;
};
birthday bth;
char num[20];
};
int main() {
struct man men[20]={0},temp;
int t;
//int year,month,day;
scanf("%d",&t);
for(int i=0; i<t; i++) {
scanf("%s%4hd%2hd%2hd%s",men[i].name,&men[i].bth.ymdh.year,&men[i].bth.ymdh.month,&men[i].bth.ymdh.day,men[i].num);
//scanf("%s %4d%2d%2d %s",men[i].name,&year,&month,&day,men[i].num);
//men[i].bth.ymdh.year=year,men[i].bth.ymdh.month=month,men[i].bth.ymdh.day=day;
}
for(int i=0; i<t-1; i++) {
for(int j=i+1; j<t; j++) {
if (men[i].bth.bday>men[j].bth.bday)
{
temp=men[i];
men[i]=men[j];
men[j]=temp;
}
}
}
for(int i=0; i<t; i++) {
printf("%s %04hd%02hd%02hd %s\n",men[i].name,men[i].bth.ymdh.year,men[i].bth.ymdh.month,men[i].bth.ymdh.day,men[i].num);
}
return 0;
}
3
zhang 19850403 13912345678
wang 19821020 +86-0571-88018448
qian 19840619 13609876543
wang 19821020 +86-0571-88018448
qian 19840619 13609876543
zhang 19850403 13912345678
|