当前位置: 首页 > news >正文

北京做网站最牛的公司找小网站的关键词

北京做网站最牛的公司,找小网站的关键词,做国际网站有用,网站建设服务天软科技C中的运算符总结&#xff08;4&#xff09;&#xff1a;逻辑运算符&#xff08;下&#xff09; 以下程序演示了如何使用条件语句和逻辑运算符根据变量的值执行不同的代码行&#xff1a; #include <iostream> using namespace std;int main() {cout << "Use …

C++中的运算符总结(4):逻辑运算符(下)

以下程序演示了如何使用条件语句和逻辑运算符根据变量的值执行不同的代码行:

#include <iostream>
using namespace std;int main()
{cout << "Use boolean values(0 / 1) to answer the questions" << endl;cout << "Is it raining? ";bool isRaining = false;cin >> isRaining;cout << "Do you have buses on the streets? ";bool busesPly = false;cin >> busesPly;// Conditional statement uses logical AND and NOTif (isRaining && !busesPly)cout << "You cannot go to work" << endl;elsecout << "You can go to work" << endl;if (isRaining && busesPly)cout << "Take an umbrella" << endl;if ((!isRaining) && busesPly)cout << "Enjoy the sun and have a nice day" << endl;return 0;
}

输出:

Use boolean values(0 / 1) to answer the questions
Is it raining? 1
Do you have buses on the streets? 1
You can go to work
Take an umbrella

再次运行的输出:

Use boolean values(0 / 1) to answer the questions
Is it raining? 1
Do you have buses on the streets? 0
You cannot go to work

最后一次运行的输出:

Use boolean values(0 / 1) to answer the questions
Is it raining? 0
Do you have buses on the streets? 1
You can go to work
Enjoy the sun and have a nice day

第 15 行包含条件表达式 (isRaining && !busesPly),可将其读作 “下雨且没有公交车”。这个表达式使用了逻辑 AND 运算符将没有公交车(对有公交车执行逻辑 NOT 运算)和下雨关联起来。

以下程序演示了如何将逻辑运算符 NOT 和 OR( ! 和 ||)用于条件处理。

#include <iostream>
using namespace std;int main()
{cout << "Answer questions with 0 or 1" << endl;cout << "Is there a discount on your favorite car? ";bool onDiscount = false;cin >> onDiscount;cout << "Did you get a fantastic bonus? ";bool fantasticBonus = false;cin >> fantasticBonus;if (onDiscount || fantasticBonus)cout << "Congratulations, you can buy that car!" << endl;elsecout << "Sorry, waiting a while is a good idea" << endl;if (!onDiscount)cout << "Car not on discount" << endl;return 0;
}

输出:

Answer questions with 0 or 1
Is there a discount on your favorite car? 0
Did you get a fantastic bonus? 1
Congratulations, you can buy that car!
Car not on discount

再次运行的输出:

Answer questions with 0 or 1
Is there a discount on your favorite car? 0
Did you get a fantastic bonus? 0
Sorry, waiting a while is a good idea
Car not on discount

最后一次运行的输出:

Answer questions with 0 or 1
Is there a discount on your favorite car? 1
Did you get a fantastic bonus? 1
Congratulations, you can buy that car!  

分析:

这个程序建议您能够打折或得到很高的补贴时就把车买了,不然就再观望观望。它还在第 19 行使用了逻辑非运算来提醒您不打折。第 14 行使用了一条 if 语句,而第 16 行是与之配套的 else 语句。在条件 (onDiscount || fantasticBonus) 为 true 时,将执行第 15 行的语句。这个表达式包含逻辑运算符||,仅当您喜欢的汽车打折或能够获得很高的补贴时, 该表达式才为 true。当该表达式为 false 时, 将执行 else语句后面的语句(第 17 行)。

该文章会更新,欢迎大家批评指正。

推荐一个零声学院免费公开课程,个人觉得老师讲得不错,
分享给大家:Linux,Nginx,ZeroMQ,MySQL,Redis,
fastdfs,MongoDB,ZK,流媒体,CDN,P2P,K8S,Docker,
TCP/IP,协程,DPDK等技术内容,点击立即学习:
服务器课程:C++服务器

学习链接

http://www.wangmingla.cn/news/14675.html

相关文章:

  • 深圳市做网站设计南宁一站网网络技术有限公司
  • 网站优化和推广方案pptaso是什么意思
  • 青岛市住房和城乡建设局官方网站西安网站制作费用
  • 如何做网络营销推广才是最正确的专业seo关键词优化
  • linux可以做网站开发吗win7优化配置的方法
  • 湖北网站建设平台镇江网站建设企业
  • 做网站的作品思路及步骤人力资源管理师
  • 网站里面添加支付怎么做免费广告发布平台
  • wordpress新建网站后台无法登陆网站开发工程师
  • 利用小程序反向做网站seo高端培训
  • 常州网站建设优质商家百度推广客服电话24小时
  • wordpress搭建多个购物网站微信广点通广告平台
  • 怎么做微信推送 网站关于市场营销的100个问题
  • 湖州网站seo优化自媒体账号申请
  • 网站建设公司如何提供客户服务公司推广方法有哪些
  • 做T恤卖网站网络推广怎么学
  • 网站后缀有哪些东莞seo建站推广费用
  • 赤壁市建设局网站如何找友情链接
  • wordpress+外网无法访问淘宝关键词怎么优化
  • 网站地图 百度站长工具seo综合查询推广
  • 西安营销型网站建设动力无限怎么让某个关键词排名上去
  • 分类信息网站建设方案新闻发布系统
  • ssm做的直播网站百度电话号码
  • 做冻品的网站教育机构排名
  • 萧山建设银行招聘网站进入百度一下官网
  • 曲周网站建设新浪疫情实时数据
  • 17做网店网站seo怎么读
  • iis7 无法添加网站百度搜索引擎营销如何实现
  • 网站维护工程师月薪多少品牌网站设计
  • 关注公众号在哪里查找seo快速排名的方法