急!!!高难度c语言编程题,高手请进帮忙!!! 10
有一函数:{x(-5<x<0)y={x-1(x=0){x=1(0<x<10)编写一程序,要求输入x的值(x为整型),输出y的值。分别用(1)if语句(2)switch语句...
有一函数: { x (-5<x<0)
y={ x-1 (x=0)
{ x=1 (0<x<10)
编写一程序,要求输入x的值(x为整型),输出y的值。
分别用(1)if语句
(2)switch语句 展开
y={ x-1 (x=0)
{ x=1 (0<x<10)
编写一程序,要求输入x的值(x为整型),输出y的值。
分别用(1)if语句
(2)switch语句 展开
6个回答
展开全部
很简单
#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();
}
就是这个了。
#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();
}
就是这个了。
展开全部
switch(x%1)
{
case '-4':case '-3':case ''...
case '0': if(x==0)。。。
}
你知道了吧!
{
case '-4':case '-3':case ''...
case '0': if(x==0)。。。
}
你知道了吧!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#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版的楼上已给出了大意,你可以自己编一下。
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版的楼上已给出了大意,你可以自己编一下。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
问题什么意思?
函数在哪了?
函数在哪了?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
什么意思啊。大括号乱括
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
很简单
#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();
}
就是这个了。
#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();
}
就是这个了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询