用whlie语句。输入10个整数,求最大值和最小值平均值。为什么不能这样写啊
#include <stdio.h>int main()
{
int counter,total,x,max,min;
double average;
counter=1;
total=0;
printf("请输入整数:");
scanf("%d", &x);
while (counter <= 9)
{
max=x;
min=x;
counter++;
printf("请输入整数:");
scanf("%d", &x);
if(min > x)
min=x;
if(max > x)
max=x;
}
printf("最小值是:%d\n", min);
printf("最大值是:%d\n", max);
printf("平均值是:%d\n", total / 10.0);
return 0;
}