目录
switch-if的简单用法
面对一些多选项的printf输出,我们总是会不断的列出else if,为了解决这个多重判断的繁琐,我们接下来用一个多路分支switch-case,为了更好地展示else if和switch-if的区别,我来展示这个代码。
#include <stdio.h>
int main()
{
int type;
scanf("%d",&type);
if(type==1)
printf("222");
else if(type==2)
printf("333");
else if(type==3)
printf("444");