网友您好, 请在下方输入框内输入要搜索的题目:
下列程序的功能是:已知学生的记录由学号和三门学习成绩构成,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+m.s2+m.s3);
readwritedat ( );
}
void readwritedat ( )
{
FILE *rf, *wf;
STU a[N] ,m;
int i;
rf=fopen ( "in. dat", "r" );
wf=fopen ( "out. dar", "w" );
for (i=0; i<10; i++)
fscanf (rf, "%s%d%d%d", a [i] .hum, &a[i] .s1, &a[i] .s2, &a [i] .s3);
mmm(a, &m);
fprintf(wf,"the top: %s,%d,%d,%d\n",m.num,m.s1,m.s2,m.s3);
fclose (rf);
fclose (wf);
}
参考答案