填空题
在主函数中从键盘输入若干个数放入数组X中,用0结束输入但不计入数组。下列给定程序中,函数FUN的功能是:输出数组元素中小于平均值的元素。
例如:数组中元素的值依次为1,2,2,12,5,15,则程序的运行结果为1,2,2,5。
注意:部分源程序给出如下
请勿改动主函数main和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:#include <conio.h>
#include <stdio.h>
void fun(___1___, int n)
{
double sum = 0.0;
double average = 0.0;
int i = 0;
for (i=0; i<n; i++)
___2___;
average = ___3___;
for (i=0; i<n; i++)
if (x[i] < average)
{
if (i%5 == 0)
printf("\n");
printf("%d, ", x[i]);
}
}
main()
{
int x[1000];
int i = 0;
printf("\nPlease enter some data(end with 0):");
do
{
scanf("%d", &x[i]);
} while (x[i++] != 0);
fun(x, i-1);
}
第1处填空:int x[]或int *x
第2处填空:sum+=x[i]或sum=sum+x[i]
第3处填空:sum/n