C语言和指针-回顾06-switch

 1 #include<stdio.h>
 2 
 3 void test_function(int input)
 4 {
 5     switch(input)
 6     {
 7         case 0:
 8             printf("input is 0\n");
 9         case 1:
10             printf("input is 1\n");
11         case 2:
12             printf("input is 2\n");
13         case 3:
14             printf("input is 3\n");
15         default:
16             printf("default\n");
17         case 4:
18             printf("input is 4\n");
19         case 5:
20             printf("input is 5\n");
21             break;
22         case 6:
23             printf("input is 6\n");
24             break;
25     }
26     printf("----------------------\n");
27 }
28 
29 int main()
30 {
31     test_function(3);
32     test_function(7);
33 }

Output :

input is 3
default
input is 4
input is 5
----------------------
default
input is 4
input is 5
----------------------

 

posted @ 2021-06-27 21:51  Erden  阅读(45)  评论(0编辑  收藏  举报