作者在 2011-06-30 18:47:42 发布以下内容
int x,i,count,max,min,sum;
float avg;
char c;
printf("请输入一组数据以回车结束\n");
scanf("%d",&x);
sum=x;
count=1;
min=x;
max=x;
for(i=0;;i++)
{
scanf("%d",&x);
c=getchar();
count++;
sum+=x;
if (x>=max)max=x;
if (min>=x) min=x;
if(c=='\n')break;
}
avg=(float)sum/count;
printf("max=%d min=%d average=%f\n",max,min,avg);
return 0;
}
float avg;
char c;
printf("请输入一组数据以回车结束\n");
scanf("%d",&x);
sum=x;
count=1;
min=x;
max=x;
for(i=0;;i++)
{
scanf("%d",&x);
c=getchar();
count++;
sum+=x;
if (x>=max)max=x;
if (min>=x) min=x;
if(c=='\n')break;
}
avg=(float)sum/count;
printf("max=%d min=%d average=%f\n",max,min,avg);
return 0;
}