-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC_state_nextstate_continue_break.c
More file actions
52 lines (48 loc) · 1.03 KB
/
Copy pathC_state_nextstate_continue_break.c
File metadata and controls
52 lines (48 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
int main (){
int count=0;
int state=0 ;
int next_state;
int enable=0;
while(!enable){ //a.k.a.for(int i=0;i<10,enable==0;i++)
if(count<6){
next_state = 1 ;
}
else if(count==6) next_state = 2;
else next_state =3 ;
switch(state){
case 0:
printf("state =%d\n",state);
printf("next_state =%d\n",next_state);
printf("count=%d\n",count);
count++;
state = next_state ;
case 1:
printf("state =%d\n",state);
printf("next_state =%d\n",next_state);
printf("miaomiaomiao\n");
count++;
state = next_state ;
continue;
case 2:
printf("state =%d\n",state);
printf("next_state =%d\n",next_state);
state = next_state ;
count++;
continue;
case 3:
printf("state =%d\n",state);
printf("next_state =%d\n",next_state);
enable=1;
break;//will not process the statement behind "break".and jump out switth
//to process "hello\n"
default:
printf("bye");
break;
} //switch end
printf("hello\n");
}//for end
printf("\n");
printf("final count=%d",count);
return 0;
}