C语言编程 题目:计算下面分段函数,输入X,输出Y Y=X-1 X<0 Y=2X-1 0<=X<=10 Y=3X-11 X>10

2025-01-21 01:51:07
推荐回答(1个)
回答1:

# include
# include

int main(void)
{
int x,y;

printf("请输入x的值:\n");
scanf("%d",&x);

if(x<0)
{
y=x-1;
}
else if(x<=10&&x>=0)
{
y=2*x-1;
}
else
{
y=3*x-11;
}

printf("y的值为:%d\n",y);

system("pause");
return 0;
}