-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathBoolTest05.lemon
More file actions
73 lines (64 loc) · 1.35 KB
/
BoolTest05.lemon
File metadata and controls
73 lines (64 loc) · 1.35 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// 测试:bool 变量赋值(true,false,方法调用)
class BoolTest05{
void main(){
bool a;
int b;
a = true && testBool();
if( a ){
b = 0;
}else{
b = 1;
}
printf("b=%d\n",b);// 1
a = !(true && testBool());
if( a ){
b = 2;
}else{
b = 3;
}
printf("b=%d\n",b);// 2
a = true && testBool() || testBool2();
if( a ){
b = 4;
}else{
b = 5;
}
printf("b=%d\n",b);// 4
a = testBool3() && testBool() || testBool2();
if( a ){
b = 6;
}else{
b = 7;
}
printf("b=%d\n",b);// 6
a = !(testBool3() && testBool() || testBool2());
if( a ){
b = 8;
}else{
b = 9;
}
printf("b=%d\n",b);// 9
a = (!(testBool3() && testBool() || testBool2())) || testBool2() && getNum(19) > 10;
if( a ){
b = 10;
}else{
b = 11;
}
printf("b=%d\n",b);// 10
}
// return false
bool testBool(){
return false;
}
// return true
bool testBool2(){
return !(false);
}
// return true
bool testBool3(){
return 1 > 2 || 3 < 5 && 19 > 1;
}
int getNum( int a){
return a;
}
}