来个大哥看看
c++吧
全部回复
仅看楼主
level 2
#include <stdio.h>
int main()
{
int x,y;
printf("please enter the x=");
scanf("%d",&x);
if(1<=x<10)
{y=2*x-1;
printf("y=%d\n",y);
}
else if(x>=10)
{y=3*x-11;
printf("y=%d\n",y);
}
else
{y=x;
printf("y=%d",y);
}
}
第一次判断总是不对,把1《 删去 才能正确判读并且执行第二条。但是不删除就永远执行第一条。请问我应该怎么编写呢?
2016年09月11日 12点09分 1
level 13
判断语句不能这么写 要写成两条 用 || 、&&连接
2016年09月11日 15点09分 2
谢谢[开心]
2016年09月13日 07点09分
level 3
你不觉得要是x大于10的话,肯定大于1吗
2016年09月11日 15点09分 4
level 3
x>1&&x<10
2016年09月11日 15点09分 5
谢谢[开心]
2016年09月13日 07点09分
1