asp教程.net bool逻辑用法
#include
using namespace std;
int main() {
bool b;
b = false;
cout << "b is " << b << "n";
b = true;
cout << "b is " << b << "n";
if(b) cout << "This is executed.n";
b = false;
if(b) cout << "This is not executed.n";
return 0;
}
实例2
#include
using namespace std;
int main() {
bool b;
b = false;
cout << "b is " << b << "n";
b = true;
cout << "b is " << b << "n";
if(b) cout << "This is executed.n";
b = false;
if(b) cout << "This is not executed.n";
return 0;
}
b is 0
b is 1
This is executed.
测试一下bool 长度
#include
int main()
{
using std::cout;
cout << "The size of a bool is:" << sizeof(bool) << " bytes.n";
return 0;
}
实例4
#include
using namespace std;
int main(void)
{
int age;
char choice;
bool citizen;
cout << "Enter your age: ";
cin >> age;
cout << "Are you a citizen (Y/N): ";
cin >> choice;
if (choice == 'Y')
citizen = true;
else
citizen = false;
if (age >= 18 && citizen == true)
cout << "You are eligible to vote";
else
cout << "You are not eligible to vote";
return 0;
}
暗影猎手失落的世界 最新版本v30.118.6.0
下载格里姆瓦勒完全版 安卓版v1.2.0
下载忍者武士暗影格斗无限金币版 安卓版v1.82.1
下载忍者必须死34399账号登录版 最新版v1.0.138v2.0.72
下载创造与魔法免登录版 手机版v1.0.0760
创造与魔法是一款高度自由的沙盒冒险手游,该游戏采用了3D最新
创造与魔法gm版 安卓版v1.0.0760
创造与魔法是一款有英雄互娱运营的一款经营沙盒建造手游,该游戏
创造与魔法变态无敌版 v1.0.0760
创造与魔法是一款3DQ版的沙盒模拟建造手游,在这里玩家需要适
腾讯普通话小镇游戏 安卓版v2.2.5
普通话小镇是由腾讯游戏追梦计划推出发行的模拟经营类型普通学习
海岛村 最新版v1.0
海岛村是一款非常好玩的模拟经营类手游,玩家在游戏中将会有一个