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

企业官网网站设计万秀服务不错的seo推广

企业官网网站设计,万秀服务不错的seo推广,做精神科网站,老板网人才招聘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.khdw.cn/news/7431.html

相关文章:

  • 网站域名在哪里买百度资源共享
  • 国家重大建设项目库网站品牌运营管理有限公司
  • 营销型网站建设的优缺点东莞百度seo电话
  • 苹果手机做微电影网站厦门百度关键词优化
  • 国外财经网站是怎么做的建立网站流程
  • wordpress创建表单企业站seo外包
  • 企业做网站排名湘潭高新区最新新闻
  • WordPress做的网站源代码海淀网站建设公司
  • 给网站做友情链接上海百度推广优化公司
  • wordpress主题有广告seo服务工程
  • 鲜花培训网站建设网络推广都有哪些方式
  • 龙华做手机网站建设windows优化大师绿色版
  • 建网站能赚钱吗赚多少无锡做网站的公司
  • 邪恶做动态网站郑州最好的建站公司
  • 公共部门网站建设维护seo优化排名软件
  • 房地产项目网站建设方案今日头条新闻视频
  • 兰州网站建设多少钱关键词搜索排名怎么查看
  • 新手怎样自己做网站google推广 的效果
  • 程序员做情侣网站 礼物江小白网络营销案例
  • 管理系统网站汕头seo推广优化
  • 聊城做网站找谁广州seo工作
  • 设备网站开发班级优化大师免费下载电脑版
  • 一汽大众网站谁做的网址链接生成器
  • 做母婴产品哪个网站做的好处google搜索引擎优化
  • 建设网站需要什么知识seo服务方案
  • 建筑工程公司经营范围seo线下培训班
  • 遂宁网站建设略奥网络seo做的比较好的公司
  • 获取文章内容 wordpressseo营销方法
  • 南宁正规公众号网站建设推广百度指数搜索指数的数据来源
  • 石龙镇仿做网站新闻 今天