/*不停地输入整数并求出它们的平均值*/
#include<stdio.h>
int main(void)
{
int retry,sum=0,count=0;
do{
int no;
printf("请输入一个整数:");
scanf("%d",&no);
sum = sum+no;
count = count+1;
printf("是否要继续?【Yes···0/No···1】");
scanf("%d",&retry);
} while(retry == 0);
printf("和为%d,平均值为%.2f\n",sum,(double)sum/count);
return 0;
}
原文地址:https://www.cnblogs.com/masic/p/12195914.html
时间: 2024-11-09 08:00:19