一道函数问题
#include <stdio.h>#include <string.h>
int fun(int score[], int m, int below[])
{
}
main( )
{ int i, n, below[9] ;void NONO ();
int score[9] = {10, 20, 30, 40, 50, 60, 70, 80, 90} ;
n = fun(score, 9, below) ;
printf( "\nBelow the average score are: " ) ;
for (i = 0 ; i < n ; i++) printf("%d ", below[i]) ;
NONO() ;
}
void NONO ()
{/* 本函数用于打开文件,输入测试数据,调用fun函数,输出数据,关闭文件。*/
int i, j, n, below[10], score[10] ;
FILE *rf, *wf ;
rf = fopen("K:\\k125\\24000208\\in.dat","r") ;
wf = fopen("K:\\k125\\24000208\\out.dat","w") ;
for(i = 0 ; i < 10 ; i++) {
for(j = 0 ; j < 10 ; j++) fscanf(rf, "%d", &score[j]) ;
n = fun(score, 10, below) ;
for(j = 0 ; j < n ; j++) fprintf(wf, "%d ", below[j]) ;
fprintf(wf, "\n") ;
}
fclose(rf) ;
fclose(wf) ;
}
低于平均分的人数作为函数值返回,低于平均分的分数放在below所在数组