南雅信息学奥赛吧 关注:11贴子:296
  • 0回复贴,共1
代码:#include<cstdio>
#include<cstring>
using namespace std;
int n;
struct node
{
char name[25];
int y,m,d;
int sum;
}a[105],t;
void qsort(int l,int r)
{
int i,j,mid;
mid=a[(l+r)/2].sum;
i=l,j=r;
while(i<=j){
while(a[i].sum <mid) i++;
while(a[j].sum >mid) j--;
if(i<=j){
t=a[i],a[i]=a[j],a[j]=t;
i++;j--;
}
}
if(i<r) qsort(i,r);
if(l<j) qsort(l,j);
}
int main()
{
int i;
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
scanf("%s",a[i].name);
scanf("%d%d%d\n",&a[i].y,&a[i].m,&a[i].d);
a[i].sum=10000*a[i].y+100*a[i].m+a[i].d;
}
qsort(1,n);
for(i=n;i>=1;i--)
{
puts(a[i].name);
}
return 0;
}


IP属地:湖北1楼2017-06-14 13:45回复