[简答题]下列程序的功能是:已知学生的记录由学号和三门学习成绩构成,N名学生的数据已有入 A数组中。找出各科及格的学生中总成绩最高的学生记录(假定最高成绩的记录中唯一的),通过形参返回。
请考生编写函数mmm(STUa[],STU*s)实现程序的要求,最后调用函数readwritedat( )把结果输出到文件out.dat中。
例如:
KS01 87 60 88
KS09 97 59 99
KS11 67 67 60
则调用该函数后,输出
the top:KS01,87, 60, 88
# include <stdio.h>
# include <string.h>
# define N 10
void readwritedat ( );
typedef struct ss
char num[10];
int s1, s2, s3;
STU;
mmm(STU a[],STU *s)
main ( )
STU a[N]=
"01", 81, 93, 92,
"02", 89, 65, 91,
"03", 66, 55, 73,
"04", 87, 91, 99,
"05", 77, 65, 91,
"06", 90, 55, 73,
"07", 79, 65, 91,
"08", 61, 55, 73,
"09", 80, 93, 92,
"10", 71, 65, 91
m;
int i;
for (i=0; i<N; i++ )
printf ("No=%s Mark=%d/n",a[i] .num, a[i] .s1,a[i] .s2,a[i].s3);
mmm (a, &m);
printf("the highest: %s,%d/n",m.num,m.s1+
[简答题]
下列程序的功能是:已知学生的记录由学号和学习成绩构成,N名学生的数据已存入数组a中,找出成绩最高的学生的记录(假定最高成绩记录是唯一的),通过形参返回。请编写函数mmm(STU a[],STU*s)实现程序要求,最后调用函数reawriteDAT( )把结果输出到文件out.dat中。
例如:KS01 87
KS09 67
KS11 97
则调用该函数后将输出:
The lowest:KS09,67
注意:部分源程序已给出。
请勿改动主函数main( )和函数readwriteDAT( )的内容。
[试题源程序]
#include<Stdio.h>
#include<string.h>
#include<conio.h>
#defime N 10
void readwriteDat( );
typedef struct ss
char num[10];int s;
STU;
void mmm(STU a[],STU*s)
msin( )
STU
a[N]="A01",81,"A02",89),"A03",81),"A01",66),"A04",87),"A05",77),"A07",79),"A08",61),"A09",80,"A10",71,),m;
int i;
System("cls");
printf("***** The original data ***** /n");
for(i=0;i<N;i++) printf("No=%s Mark=%d/n",a[i].num,a[i].s);
mmm(a,&m);
print
[填空题]下列给定程序中,函数fun( )的功能是:对N名学生的学习成绩,按从低到高的顺序找出前m(m≤10)名学生来,并将这些学生数据存放在一个动态分配的连续存储区中,此存储区的首地址作为函数值返回。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <alloc.h>
#define N 10
typedef struct SS
char num[10];
int s;
STU;
STU *fun(STU a[],int m)
STU b[N],*t;
int i, j,k;
/*************found*************/
*t=calloc(m,sizeof(STU));
for(i=0;i<N;i++)
b[i]=a[i];
for(k=0;k<m;k++)
/*************found*************/
for (i=j=0;i<N;j++)
if(b[i].s<b[j],s)
j=i;
/*************found*************/
t[k].s=b[j].s;
b[j].s=100;
return t;
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].S);
fprintf(pf,"/n/n");
main( )