编辑代码

/*
#include <stdio.h>
int main( void )
{
    int type;
    scanf("%d",&type);
	switch (type) {
	case 1:
	case 2:
	printf("你好\n");
	break;
	case 3:
	printf("晚上好\n");
	break; //omit break in this line will print "good evening goodbye".
	case 4:
	printf("再见\n");
	break;
	default:
	printf("啊,什么啊?\n");
	break;
	}
}
*/
#include <stdio.h>
int main()
{
char c;
c = getchar();
switch (c) //参数只能是整型变量
{
case '1':
printf("OK\n");
break;//switch遇到break就中断了
case '2':
printf("not OK\n");
break;
default://如果上面的条件都不满足,那么执行default
printf("are u ok?\n");
}
return 0;
}