求平均数问题,编译过程中输入一个5后回车再输入一个6就有下面的结果,为啥啊
#include<stdio.h>int main()
{
int sum=0,num=0,n=0,x=0;
scanf("%d",num);
while(num!=-1)
{
sum+=num;
n++;
scanf("%d",num);
}
x=sum/n*1.0;
printf("%f",x);
return 0;
}
5
--------------------------------
Process exited after 4.497 seconds with return value 3221225477
请按任意键继续. . .