10、给定程序中,函数fun的功能是:计算形参x所指数组中N个数的平均值(规定所有数均为正数),将所指数组中大于平均值的数据移至数组的前部,小于等于平均值的数据移至x所指数组的后部,平均值作为函数值返回,在主函数中输出平均值和移动后的数据。
例如,有10个正数:46 30 32 40 6 17 45 15 48 26,平均值为:30.500000
移动后的输出为:46 32 40 45 48 30 6 17 15 26
请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。
不得增行或删行,也不得更改程序的结构!
#include #include #define N 10
double fun(double *x)
{ int i, j; double s, av, y[N];
s=0;
for(i=0; i av=__1__;
for(i=j=0; i /**********found**********/
y[__2__]=x[i]; x[i]=-1;}
for(i=0; i if( x[i]!= __3__) y[j++]=x[i];
for(i=0; i }
main()
{ int i; double x[N]= {46,30,32,40,6,17,45,15,48,26};
for(i=0; i printf("\nThe average is: %f\n",fun(x));
printf("\nThe result :\n",fun(x));
for(i=0; i }
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|