上代码:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
struct student
{
char id[25];
int month, date;
int xu;
};
bool cmp(student a,student b)
{
int x=strlen(a.id),y=strlen(b.id);
if(a.month == b.month )
{
if(a.date == b.date)
{
if(x==y)
{
return strcmp(a.id,b.id)<0;
}
return x<y;
}
else
{
return a.date < b.date ;
}
}
return a.month < b.month ;
}
int main()
{
student stu[185];
int n;
bool isBegin = true, isFirst = true;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%s %d %d", &stu[i].id, &stu[i].month, &stu[i].date);
stu[i].xu = i ;
}
sort(stu, stu+n, cmp);
for(int i = 0;