3.4 逻辑运算符
//逻辑运算符 --- 非
int main() {
int a = 10;
cout << !a << endl; // 0
cout << !!a << endl; // 1
system("pause");
return 0;
}最后更新于
//逻辑运算符 --- 非
int main() {
int a = 10;
cout << !a << endl; // 0
cout << !!a << endl; // 1
system("pause");
return 0;
}最后更新于
//逻辑运算符 --- 与
int main() {
int a = 10;
int b = 10;
cout << (a && b) << endl;// 1
a = 10;
b = 0;
cout << (a && b) << endl;// 0
a = 0;
b = 0;
cout << (a && b) << endl;// 0
system("pause");
return 0;
}//逻辑运算符 --- 或
int main() {
int a = 10;
int b = 10;
cout << (a || b) << endl;// 1
a = 10;
b = 0;
cout << (a || b) << endl;// 1
a = 0;
b = 0;
cout << (a || b) << endl;// 0
system("pause");
return 0;
}