#include
void main()
{
printf("1.plus +\n");
printf("2.subtract -\n");
printf("3.times *\n");
printf("devided by /\n");
printf("Please choose nunber:");
int a,b,c;
scanf("%d",&a);
printf("Input 2 nunbers:");
scanf("%d%d",&b,&c);
switch(a) //a的取值情况
{
case 1: printf("%d",b+c); break; //a为1时,做加法运算,输出结果,并推出switch语句
case 2: printf("%d",b-c); break; //a为2时,做减法运算,输出结果,并推出switch语句
case 3: printf("%d",b*c); break; //a为3时,做乘法运算,输出结果,并推出switch语句
case 4: printf("%d",b/c); break; //a为1时,做除法运算,输出结果,并推出switch语句
}
}
#include
void main()
{
int n;
scanf("%d",&n);
switch(n)
{
case 1: printf("你输入的是1");
break;
case 2: printf("你输入的是2");
break;
default: printf("你输入的是其他数字");
break;
}
}
int a;
scanf("%d",&a);
switch(a%100)
{case 0:printf("0");break;
case 1:printf("1");break;
case 2:printf("2");break;
case 3:printf("3");break;
case 4:printf("4");break;
case 5:printf("5");break;
case 6:printf("6");break;
case 7:printf("7");break;
case 8:printf("8");break;
case 9:printf("9");break;
case 10:printf("10");break;
case 11:printf("11");break;
case 12:printf("12");break;
case 13:printf("13");break;
case 14:printf("14");break;
case 15:printf("15");break;
case 16:printf("16");break;
case 17:printf("17");break;
case 18:printf("18");break;
case 19:printf("19");break;
default :break;
}
#include
int main()
{
int num;
printf("输入一个数:");
scanf("%d", &num);
switch (num)
{
case 1:
printf("你输入的是1");
break;
case 2:
printf("你输入的是2");
break;
default:
printf("其它");
}
while (1)
;
return 0;
}
#Iinclude
int main()
{
int iJudge;//make a defination,iJudge is the base of "switch"
scanf("%d",&iJudge);
switch(iJudge)
{
case 1:
printf("You are a good man!");//if iJudge==1,than print "You are a good man" on screen
break;
case 2:
prinf("You are a bad man!");//if iJudge==2,than print "You are a bad man" on screen
break;
default://if iJudge not match witch 1or 2,than break;
break;
}
return 0;//exit this program
}