49、学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组s中,请编写函数fun,它的功能是:把低于平均分的学生数据放在b所指的数组中,低于平均分的学生人数通过形参n传回,平均分通过函数值返回。
注意: 部分源程序在文件PROG1.C中。
请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
#include #define N 8
typedef struct
{ char num[10];
double s;
} STREC;
double fun( STREC *a, STREC *b, int *n )
{ }
main()
{ STREC s[N]={{"GA05",85},{"GA03",76},{"GA02",69},{"GA04",85},
{"GA01",91},{"GA07",72},{"GA08",64},{"GA06",87}};
STREC h[N],t;FILE *out ;
int i,j,n; double ave;
ave=fun( s,h,&n );
printf("The %d student data which is lower than %7.3f:\n",n,ave);
for(i=0;i printf("\n");
out = fopen("c:\\test\\out.dat","w") ;
fprintf(out, "%d\n%7.3f\n", n, ave);
for(i=0;i for(i=0;i fclose(out);
}
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15080520号-20 珠峰网 版权所有 All Rights Reserved
|