scanf 与数组结合,会导致无限输入,一直不往下运行,为什么?
#include <stdio.h>int main (void)
{
int x;
double sum = 0;
int cnt = 0;
int number[10];
scanf("%d", &x);
while(x != -1)
{
number[cnt] = x;
sum += x;
cnt ++;
scanf ("%d", &x);
}
if(cnt > 0)
{
printf("%f\n", sum / cnt);
}
return 0;
}