C语言switch语句相关问题~要求用switch语句描述x>0时,y=1;x==0时,y=C语言switch语句相关问题~要求用switch语句描述x>0时,y=1;x==0时,y=0;x<0时,y=-1

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 08:40:33

C语言switch语句相关问题~要求用switch语句描述x>0时,y=1;x==0时,y=
C语言switch语句相关问题~
要求用switch语句描述x>0时,y=1;x==0时,y=0;x<0时,y=-1

switch(x)
{
case 0:y=0;break;
default:(x>0)?y=1:y=-1;
}