c语言,从键盘输入若干个整数,用-1作为输入结束的标志,求他们的和及平均值 相关知识点: 试题来源: 解析 #includeint main(void){int count=0, n, sum=0; whlie(scanf("%d",&n)!=EOF){if(n==-1)break;else sum+=n;count++}printf("%d, %lf\n", sum, sum*1.0/count);return 0;}...
int main(void){int count=0, n, sum=0; whlie(scanf("%d",&n)!=EOF){if(n==-1)break;else sum+=n;count++}printf("%d, %lf\n", sum, sum*1.0/count);return 0;} 解析看不懂?免费查看同类题视频解析查看解答 相似问题 从键盘输入一组非0整数,以输入0标志结束,求这组整数的平均值,并...
include<stdio.h> int main(){ int x;double sum=0,pj;int cnt=0;scanf("%d",&x);while(x!=-1){ sum+=x;cnt++;scanf("%d",&x);} if(cnt>0){ pj=sum/cnt;printf("%.2f\n",pj);} return 0;}