编辑代码

#include <stdio.h>
int main()
{	
	int x,c; double y;
	scanf("%d",&x);
	if (x<0) c=-1 ;   /*1*/
	else c=x/10;       /*2*/
	switch (c) {
		case -1	: y=0.0 ; break ;
		case 0	: y=x ; break ;
		case 1	: y=10.0 ; break ;
		case 2	:
		case 3	: y=-0.5*x+20 ; break ;
		default: y=-2.0 ;
	}
	if (x<40||y!=-2.0)    /*y<40||y!=-2.0*/
		printf("y=%lf",y);
	else
		printf("error!");
   return 0;
}