急!!!高难度c语言编程题,高手请进帮忙!!!

有一函数: { x (-5<x<0)
y={ x-1 (x=0)
{ x=1 (0<x<10)
编写一程序,要求输入x的值(x为整型),输出y的值。
分别用(1)if语句
(2)switch语句

很简单

#include<stdio.h>
void main()
{
int ix,iy;
printf("please input the data of x:");
scanf("%d",&ix);
if(x<-5&&x>0)
printf("the y is :%d",ix);
if(x==0)
{
iy=ix-1;
printf("the y is:%d"&iy);
}
if(x<0&&x<10)
printf("the y is: 1");
printf("input any key to quit!");
gech();
}
这是if的
#include<stdio.h>
void main()
{
int ix,iy,entrance;
printf("input the x:");
scanf("%d",ix);
if(x<-5&&x>0)
entrance=1;
if(x==0)
{
entrance=2;
}
if(x<0&&x<10)
entrance=3;
switch(entrance)
case 1: printf("the y is :%d",ix);break;
case 2: printf("the y is :%d,ix-1");break;
case 3: printf("the y is : 1");break;
printf("input any key to quit!");
getch();

}
就是这个了。
温馨提示:内容为网友见解,仅供参考
第1个回答  2008-03-18
switch(x%1)
{
case '-4':case '-3':case ''...
case '0': if(x==0)。。。

}
你知道了吧!
第2个回答  2008-03-18
#include<stdio.h>
void main(){
int x,y;
printf("input x\n");
scanf("%d",&x);
if(x<10 && x >0)
y = x+1;
else if(x == 0)
y = x-1;
else if(x> -5 && x<0)
y = x;
printf("y=%d",x);
}
swith版的楼上已给出了大意,你可以自己编一下。
第3个回答  2008-03-19
问题什么意思?

函数在哪了?
第4个回答  2008-03-18
什么意思啊。大括号乱括
第5个回答  2019-11-04
很简单
#include<stdio.h>
void
main()
{
int
ix,iy;
printf("please
input
the
data
of
x:");
scanf("%d",&ix);
if(x<-5&&x>0)
printf("the
y
is
:%d",ix);
if(x==0)
{
iy=ix-1;
printf("the
y
is:%d"&iy);
}
if(x<0&&x<10)
printf("the
y
is:
1");
printf("input
any
key
to
quit!");
gech();
}
这是if的
#include<stdio.h>
void
main()
{
int
ix,iy,entrance;
printf("input
the
x:");
scanf("%d",ix);
if(x<-5&&x>0)
entrance=1;
if(x==0)
{
entrance=2;
}
if(x<0&&x<10)
entrance=3;
switch(entrance)
case
1:
printf("the
y
is
:%d",ix);break;
case
2:
printf("the
y
is
:%d,ix-1");break;
case
3:
printf("the
y
is
:
1");break;
printf("input
any
key
to
quit!");
getch();
}
就是这个了。
相似回答
大家正在搜