-
Notifications
You must be signed in to change notification settings - Fork 1
/
75goto关键字.c
61 lines (54 loc) · 1.34 KB
/
75goto关键字.c
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
53
54
55
56
57
58
59
60
61
/*goto 关键字*/
//让指令能够不受条件跨越执行.简化代码
#include <stdio.h>
int main(){
int a=0;
if(a==0){
goto heima;
}
printf("itcast\n");//这行不会执行
printf("itcast\n");//这行不会执行
printf("itcast\n");//这行不会执行
printf("itcast\n");//这行不会执行
int b=0;
heima:printf("heima--%d\n",b);//直接跳到这里执行
int c=0;
// for (int i=0; i<10; i++) {
// printf("i~~\n");
// if(c==5){
// break;
// }
// c++;
// for (int f=0; f<10; f++) {
// printf("f~~\n");
// if(c==5){
// break;
// }
// c++;
// for (int e=0; e<10; e++) {
// printf("e~~\n");
// c++;
// if(c==5){
// break;
// }
//
// }
// }
// }
for (int i=0; i<10; i++) {
printf("i~~\n");
c++;
for (int f=0; f<10; f++) {
printf("f~~\n");
c++;
for (int e=0; e<10; e++) {
printf("e~~\n");
c++;
if(c==5)goto haha;
}
}
}
printf("哈哈,我跳出了~~\n");
haha:printf("哈哈,我跳出了~~\n");
return 0;
}