作业帮 > 综合 > 作业

关于c语言for循环break的使用

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/17 02:04:59
关于c语言for循环break的使用
代码如下:

为什么输入n也不好使?还循环两次.
Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):y
Do you want to enter some more(y/n):Do you want to enter some more(y/n):
在scanf和if之间加上函数getchar();
就好了.但为什么

在输入很多e之后,在输入n就退步出来了?
关于c语言for循环break的使用
清空一下缓冲区就可以了printf("Do you want to enter some more(y/n):");
fflush(stdin);
scanf("%c", &answer);
...
再问: 厉害!