关于这个 while 为何会循环打印 2 次
程序代码:
#include<stdio.h> int main(void) { int guess=1; printf("Uh..is your number %d?\n",guess); while(getchar()!='y') printf("Well,then,is it %d?\n",guess++); printf("i konw i could do it\n"); return 0; }
首先打印Uh..is your number 1
然后要求输入,如果等于Y,打印i konw i could do it
如果等于N,打印Well,then,is it %d?
假如如下
Uh..is your number 1?
键入n
Well,then,is it 2?
n
Well,then,is it 3?
y
i konw i could do it
这个是预期结果,可是为什么每次输入N后就连续打印2次
Well,then,is it 2?
Well,then,is it 3?
n
Well,then,is it 4?
Well,then,is it 5?