用switch语句编程实现以下函数关系:
用switch语句编程实现以下函数关系:

答案
#include<stdio.h>
int main()
{
float x;
int y;
printf("\n input x:");
scanf("%f",&x);
switch (x<0)
{
case 1:
y=-1;
break;
case 0:
switch(x==0)
{
case 1:y=0;
break;
default:y=1;
}
}
printf("\n y=%d",y);
return 0;
}