求高手帮忙啊,程序不合适啊
#include <stdio.h>#include <string.h>
int n=3;
struct student
{
char num[5];
char name[20];
int score[4];
}
st[]={{"2010","linning",43,22,44,54},{"2012","yanglin",53,54,55,34},{"2011","liuhua",55,64,34,66}};
pxnum()
{
struct student *p=st;
struct student temp;
int i,j;
for(i=0;i<n-1;i++)
for(j=0;j<n-1;j++)
if(strcmp(p+j)->num,(p+j+1)->num)>0)
temp=*(p+j);
*(p+j)=*(p+j+1);
*(p+j+1)=temp;
print();
{
int i;
printf("num name score\n");
printf("------------------------\n");
for(i=0;i<n;i++)
printf("%-8s%-10s %d,%d,%d,%d\n",st[i].num,st[i].name,st[i].score[0],st[i].score[1],st[i].score[2],st[i].score[3]);
}
}
main()
{
pxnum();
print();
}