逻辑变量logic variable

bool:

     0   false

     1   true. (非零)

    bool a,b;   定义逻辑变量;

     a=true;

    b=false;

   a&&b    a||b

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
//bool
#include<iostream> 
using namespace std; 
int main() 
{ 
	bool b1=true, b2=false; 
	cout << "b1 is = " << b1 << "\n"; 
	cout << "b2 is = " << b2 << "\n"; 
	if (b1) cout << "Yes" << "\n"; 
	else cout << "No" << "\n"; 

	if(b1&&b2)	cout << "Yes" << "\n"; 
	else cout << "No" << "\n"; 
	
return 0; 
	
} 
Scroll to Top