定义一个具有100个元素的整型数组,从键盘输入数据,求这些数据的累加和及平均值,当输入0时结束。

输入的正整数个数n<=100

#include<stdio.h>
main()
{   int n[100],sum=0,i=0;
    scanf("%d",&n[0]);
    while(n[i]!=0){
sum+=n[i];
i++; 
scanf("%d",&n[i]);
}
printf("sum = %lf\n",(double)sum/i);
}

如图所示,望采纳。。。。。。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-11-06
要代码请追问,我发了三遍都发不过,这破系统追问

谢谢大佬

相似回答