[code=Cpp width=740px]#include <stdio.h>
struct note
{
int num;
char name[21];
char aut[21];
}a[51];
int cmp(const void *x,const void *y)
{
if( (*((struct note *)x)).num > (*((struct note *)y)).num)
return 1;
else
return 0;
}
int main()
{
int n;
int i;
freopen("111.in","r",stdin);
freopen("111.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a.num);
getchar();
gets(a.name);
gets(a.aut);
}
qsort(&a[1],n,sizeof(a[0]),cmp);
for(i=1;i<=n;i++)
{
printf("%d\n%s\n%s\n",a.num,a.name,a.aut);
}
sleep(3000);
return 0;
}[/code]
|