1#include <stdio.h>2 intMain ()3 {4 intn=5;5 Switch(n) {6 Case 0: Do{7 Case 1:p rintf ("1");8 Case 2:p rintf ("2");9 Case 3:p rintf ("3");Ten Case 4:p rintf ("4"); One Case 5:p rintf ("5"); A default: n--; -} while(n>2); - } theprintf"\ n"); - return 0; -}
The switch statement mechanism is the same as the Goto statement (similar?). ), you can implement an unconditional jump. -This is the more reliable answer I can ask.
1 Goto Label; 2 Do {3 Label: 4 printf ("123"); 5 } while (0);
There is no difference between jumping to the middle of a loop with a goto and jumping into the loop with a switch, and the case determines the starting position. called the label statement. Here switch (n) jumps directly to the execution of the sentence case 5 there, output 5, and then still in the Do...while loop, at this time the case in Do...while, the default has been invalidated, that is, directly after the execution of their statements, step-up execution, until n=2, Loop end. Running result: 51234512345.
Do...while in "A piece of code" switch