East 编辑个性签名 VIP 正式会员 注册 2020/04/24 消息 266 金粒 5,417金粒 2021/06/27 #1 C: #include <stdio.h> int main() {//求平均数 double a=0; //数的和 int b=0; //数的数量 double c; //数 printf("输入数值,-1结束\n"); scanf("%lf",&c); while(c!=-1){ a+=c; b++; printf("输入数值\n"); scanf("%lf",&c); }; printf("结果为%f",a/b); return 0; }
C: #include <stdio.h> int main() {//求平均数 double a=0; //数的和 int b=0; //数的数量 double c; //数 printf("输入数值,-1结束\n"); scanf("%lf",&c); while(c!=-1){ a+=c; b++; printf("输入数值\n"); scanf("%lf",&c); }; printf("结果为%f",a/b); return 0; }