试题程序: #include<stdio.h> #include<malloc.h> #include<string.h> #include<conio.h> #define N 10 typedef struct ss char num[10]; int order; STU; STU*fun(STU a[],int m) STU b[N],*tt; int i,j,k; (1) ; for(i=0;i<N;i++) b[i]=a[i]; for(k=0;k<m;k++) for(i=j=0;i<N;i++) if( (2) ) j=i; tt[k]=b[j]; b[j].order=0; return (3) ; outresult(STU a[],FILE*pf) int i; for(i=0;i<N;i++) fprintf(pf,"No=%s Mark=%d\n" ,a[i].num,a[i].order); fprintf(pf,"\n\n"); main() STU[N]="A01",80,"A02",79, "A03",66,"A04",82,"A05",87, "A06",93,"A07",78,"A08",60, "A09",85,"A10",73; STU * p_order; int i,m; clrscr(); printf("* * * The Origial data * * *\n"); outresult(a,stdout); printf("\nGive the numeber of the students who have better score:"); scanf("%d",&m); while(m>10)
printf("\nGive the number of the studets who have better score:"); scanf("%d",&m);
p_order=fun(a,m); printf("* * *THE RESULT* * *\n"); printf("* * * The top students * * *\n"); for(i=0;i<m;i++) printf("%s %d\n",p_order[i].num,p_order[i].order); free(p_order);