1 #include <iostream> 2 int main() 3 { 4 using namespace std; 5 int x; 6 7 cout<<"The expression x=100 has the value "; 8 cout<<(x=100)<<endl; 9 cout<<"Now x= "<<x<<endl; 10 cout<<"The expression x<3 has the value "; 11 cout<<(x<3)<<endl; //像x<3这样的关系表达式将被判定为bool值true和false 12 cout<<"The expression x>3 has the value "; 13 cout<<(x>3)<<endl; //但cout将在显示bool值之前将它们转换成int 14 cout.setf(ios_base::boolalpha);//该函数调用设置了一个标记,该标记命令cout显示true和false,而不是0和1 15 cout<<"The expression x<3 has the value "; 16 cout<<(x<3)<<endl; 17 cout<<"The expression x>3 has the value "; 18 cout<<(x>3)<<endl; 19 return 0; 20 }