include
void main(){
int a;
scanf(“%d”,&a);
switch(a){
case 1: break;
case 2: break;
default:
}
}
switch后表达式可为int,char,不可是float,double。
每个case值必须不相同。case后必须是常量。多个case可共用一个语句。每个语句后必须加break。