该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
char a;
int n,b,i=1;
int y=2;
printf("let's play a game that you choose a number but don't tell me and i will check out it\n");
printf("if my answer is too big input b and it is too small in put s,if i'm right input r.now input max number\n");
scanf("%d",&b);
n=floor(b*1.0/2.0);
printf("it is %d?\n",n);
while(1){
scanf("%c",&a);
switch(a)
{
case 'R':
printf("I'm right ha only %d",i);
return 0;
case 'b':
n=n-floor(n*1.0/y);
printf("it is %d?\n",n);
y=y*2;
break;
case 's':
n=n+floor(n*1.0/y);
printf("it is %d?\n",n);
break;
default:
break;
}
i=i+1;
}
为什么程序执行完一次之后,不等你输入又会立马执行一次,输出default。然后才能输入新的值呢?