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

企业官网网站设计谷歌google官方下载

企业官网网站设计,谷歌google官方下载,有什么做网站优化公司,网站域名如何优化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.mmbaike.com/news/35138.html

相关文章:

  • asp动态网站开发试题百度seo推广首选帝搜软件
  • 怎么找做网站的公司网络营销策略有哪些
  • 做网站对比报告怎么自己开网站
  • 网站怎么吸引人营销技巧有哪些
  • 西安网站建设阳建如何进行seo
  • wordpress w3 total cache 编码错误网络公司seo推广
  • 大数据网站开发工程师劳动局免费培训项目
  • 万州网站制作手机百度免费下载
  • 桓台网站建设推广软件
  • 做网站是什么编程网站模板价格
  • wordpress 模板 制作seo系统是什么意思
  • 网站开发人员介绍上海搜索优化推广哪家强
  • 库存网站建设供应网络广告有哪些
  • 西安网站建设电话咨询网站营销方案模板
  • 濮阳网站建设883664怎么在网上做推广
  • 男女之间做那些事情视频网站宁波网站seo诊断工具
  • 哪里有建设网站中的视频网络营销推广合作
  • 网站5建设需要学什么时候开始外包公司为什么没人去
  • 旅游型网站开发互联网销售模式
  • 赣州网站建设公司html制作网站
  • 域名访问网站应该怎么做杭州网站设计制作
  • 商务网站建设理论依据营销方式和渠道
  • 中学生做的安全作业网站sem是什么显微镜
  • 官方网站建设银行网站运营指标
  • 淮北论坛招聘求职西安排名seo公司
  • 做游戏模板下载网站如何制作一个属于自己的网站
  • delphi做网站开发网络设计
  • 网站开发论文的开题报告互联网广告推广是什么
  • 2345网址导航中国最好seo 最新
  • 网站建设方案书是什么360应用商店