比如设计一个过关的小游戏场景,根据提示输入一个数字,然后根据数字进入相应的关卡。
#include <stdio.h>
int main(){
int num;
printf("please enter cencorship:");
scanf("%d",&num);
if(num==1){
printf("the current into first level\n");
}else if(num==2){
printf("the current into second level\n");
}else if(num==3){
printf("the current into third level\n");
}else{
printf("the current into %d level\n",num);
}
return 0;
}
相应图示如下: