问答题
下列给定程序中,函数fun的功能是:对N名学生的学习成绩,按从高到低的顺序找出前m(m≤10)名学生来,并将这些学生的数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。 请改正程序中的错误,使它能得出正确的结果。 注意:不得增行或删行,也不得更改程序的结构! 试题程序:#inelude<stdlib.h>#include<eonio.h>#include<string.h>#include<stdio.h>#include<malloe.h>#define N 10typedef struet s8{ char nunl[10]; int s;}STU;STU*fun(STU a[],int m){ STU b[N],*t; int i,j,k;/*******found*******/ *t=calloe(In,sizeof(STU)); for(i=0;i<N;i++) b[i]=a[i]; for(k=0;k<m;k++) { for(i=j=0;i<N;i++) if(b[i].s>b[j].s) j=i;/*******found*******/ t[k].num=b[j].hum; t[k].8=b[j].s; b[j].8=0; } return t;}outreult(STU 8[],FILE*pf){ int i; for(i=0;i<N;i++) fprintf(pf,“No=%8 Mark=%d\n”, a[i].hum,a[i].s);fprinff(pf,“\n\n”);}void main(){STU a[N]={{“A01”,81},{“A02”,89},{“A03”,66},{“A04”,87},{“A05”,77},{“A06”,90},{“A07”,79},{“A08”,61},{“A09”,80},{“AIO”,71}};STU*pOrder;int i,m;system(“CLS”);printf(“******THE RESULT******\n”); outresult(a,stdout); prinff(”\nGive the number of the studentswho have better score:”); scanf(“%d”,&m); while(m>10) { printf(“\nGive the number of the students who have better score”); scanf(“%d”,&m); } pOrder=fun(a,111); prinff(“******THE RESULT******\n”); prinff(“The top:\n”); for(i=0;i<m;i++) printf(“%s%d\n”,pOrder[i].RUm,pOrder[i].8); free(pOrder);}