小白问题,一个书本上的for循环例题,我编出来结果不对,求指点
#include <stdio.h>#include <ctype.h>
int main (void)
{
char ifcontinue = "n";
double value = 0.0;
double average =0.0;
double total = 0.0;
int count = 1;
for ( ; ; )
{
printf("\nyou can enter a number:");
scanf("%lf",&value);
total += value;
++count;
printf("do you want to continue? (Y or N):");
scanf("%c", &ifcontinue);
if (tolower(ifcontinue) == 'n')
break;
}
average = value/count;
printf("/n you enter %d numbers, and the average is %lf", count ,average);
return 0;
}
这是我自己编的,我感觉和课本的差不多啊,但是运行的时候 出现那个do you want to continue 以后也没出现要我填Y/N的地方,直接又回去了出现了you can enter a number, 求指点,谢谢