程序填空题:求均值
计算并输出一个非零整数序列(序列非空)中偶数的平均值。所有输入数据用空格隔开,用0结束输入。输出数据保留2位小数。
```c++
#include
int main()
{
int number;
int sum,n;
double average;
n = 0;
sum = 0;
scanf("%d",&number);
while(@@[number != 0](1)){
if(number%2 == 0){
sum += number;
n ++;
}
@@[scanf("%d",&number)](2);
}
@@[average = sum*1.0/n](2);
printf("%.2lf\n",average);
return 0;
}
```
答案:
第1空:number != 0
第2空:scanf("%d",&number)
第3空:average = sum*1.0/n
```c++
#include
int main()
{
int number;
int sum,n;
double average;
n = 0;
sum = 0;
scanf("%d",&number);
while(@@[number != 0](1)){
if(number%2 == 0){
sum += number;
n ++;
}
@@[scanf("%d",&number)](2);
}
@@[average = sum*1.0/n](2);
printf("%.2lf\n",average);
return 0;
}
```
答案:
第1空:number != 0
第2空:scanf("%d",&number)
第3空:average = sum*1.0/n