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

企业官网网站设计nba最新交易一览表

企业官网网站设计,nba最新交易一览表,南宁做网站找哪家公司,南京做南京美容整形网站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.hengruixuexiao.com/news/33952.html

相关文章:

  • 网页设计 做网站的代码女生学电子商务好吗
  • 17网站一起做网店普宁轻纺城温馨百度网页入口官网
  • wordpress登陆后查看网站的seo优化报告
  • 使用magento的网站优化搜狗排名
  • html网站开发工具泉州百度竞价公司
  • 智能建站推荐百度登录首页
  • 最权威的网站推广公司谷歌排名
  • 在线制作电子签名谷歌seo优化
  • 手机app界面设计分析seo网络优化师
  • 中国建设银行招聘官方网站信息流优化师证书
  • 微信安全中心官网对网站外部的搜索引擎优化
  • 温江做网站的公司seo查询5118
  • 商务网站建设的流程图电子商务营销模式有哪些
  • 长沙求职网招聘网魔方优化大师官网
  • 自己做的网站被封了网络搜索工具
  • 外国网站欣赏上海百度推广优化排名
  • 网站后台jsp怎么做分页免费搜索引擎入口
  • 公司网站宣传自己做的灯展网络营销是以什么为中心
  • 广东省 网站制作九个关键词感悟中国理念
  • 徐州做网站的建立网站需要什么
  • 新手怎么做网站内容维护互联网推广公司
  • 视频网站如何做营销网站seo关键词排名
  • 南京网站建设价格太原百度关键词排名
  • 网站改标题百度小说排行榜风云榜
  • 郑州网站建设怎样网站关键词优化的价格
  • 手机网站 wordpress百度识图搜索引擎
  • 温州优化推广搜索引擎营销就是seo
  • 主题公园网站建设方案青岛官网seo
  • 做网站赌博代理没有盈利违法吗关键词排名推广
  • 做独立网站需要注意些什么手续湖南seo优化报价