#include <stdio.h>
int main()
{
//两种方式,输入X的值,来算出Y的值。
int x;
int y;
puts("请输入x的值");
scanf("%d",&x);
if(x<1){
printf("%d\n",y=x);
y=x;
}else if(x>=1&&x<10){
printf("%d\n",y=(2*x)-1);
y=(2*x)-1;
}else if(x>=10){
printf("%d\n",y=(3*x)-11);
y=(3*x)-11;
}
printf("y的值是:%d\n",y);
puts("请输入x的值");
scanf("%d",&x);
switch(x){
case 0:
y=x;
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
y=(2*x)-1;
break;
default:
y=(3*x)-11;
}
printf("y的值是:%d\n",y);
return 0;
}
12-17
2401
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交