c语言switch格式求年龄差,求助各位大佬。关于switch的。

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

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。然后才能输入新的值呢?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值