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

运算符(个人学习笔记黑马学习)

算数运算符

 加减乘除

#include <iostream>
using namespace std;int main() {int a1 = 10;int a2 = 20;cout << a1 + a2 << endl;cout << a1 - a2 << endl;cout << a1 * a2 << endl;cout << a1 / a2 << endl;/*double a3 = 0.5;double a4 = 0.25;cout << a3 / a4 << endl;*/double a3 = 0.5;double a4 = 0.22;cout << a3 / a4 << endl;//运算结果也可以是小数system("pause");return 0;
}


取模  

#include <iostream>
using namespace std;int main() {int a1 = 10;int b1 = 3;cout << a1 % b1 << endl;/*两个小数之间不可以做取余运算double d1 = 0.2;double d2 = 0.55;count << d1 % d2 << endl;*/system("pause");return 0;
}


自增自减 

#include <iostream>
using namespace std;int main() {//前置int a2 = 10;int b2 = ++a2 * 10;cout << "a2 = " << a2 << endl;cout << "b2 = " << b2 << endl;//后置int a3 = 10;int b3 = a3++ * 10;cout << "a3 =" << a3 << endl;cout << "b3 =" << b3 << endl;system("pause");return 0;
}

  


赋值运算符

#include <iostream>
using namespace std;int main() {// =int a = 10;a = 100;cout << "a=" << a << endl;// +=a = 10;a += 2;cout << "a=" << a << endl;// -=a = 10;a -= 2;cout << "a=" << a << endl;// *=a = 10;a *= 2;cout << "a=" << a << endl;// /=         a = 10;a /= 2;cout << "a=" << a << endl;// %=a = 10;a %= 2;cout << "a=" << a << endl;system("pause");return 0;
}


比较运算符 

#include <iostream>
using namespace std;int main() {//==int a = 10;int b = 20;cout << (a == b) << endl;//!=cout << (a != b) << endl;//>cout << (a > b) << endl;//<cout << (a < b) << endl;//>=cout << (a >= b) << endl;//<=cout << (a <= b) << endl;system("pause");return 0;
}


逻辑运算符 

逻辑非!

#include <iostream>
using namespace std;int main() {int a = 10;cout << !a << endl;cout << !!a << endl;system("pause");return 0;
}


逻辑与&& 

#include <iostream>
using namespace std;int main() {int a = 10;int b = 10;cout << (a && b) << endl;a = 0;b = 10;cout << (a && b) << endl;a = 0;b = 0;cout << (a && b) << endl;system("pause");return 0;
}


逻辑或|| 

#include <iostream>
using namespace std;int main() {int a = 10;int b = 10;cout << (a || b) << endl;a = 0;b = 10;cout << (a || b) << endl;a = 0;b = 0;cout << (a || b) << endl;system("pause");return 0;
}

http://www.lryc.cn/news/144996.html

相关文章:

  • 开源与专有软件:比较与对比
  • openResty+lua+redis实现接口访问频率限制
  • 自动化测试(三):接口自动化pytest测试框架
  • Python --datetime模块
  • 顺序表链表OJ题(3)——【数据结构】
  • 【Azure】Virtual Hub vWAN
  • React Navigation 使用导航
  • 双指针算法,基础算法实践,基本的算法的思想,双指针算法的实现
  • idea http request无法识别环境变量
  • 性能测试常见的测试指标
  • 并发 04(Callable,CountDownLatch)详细讲解
  • Json路径表达式
  • 【uniapp 上传图片示例】
  • apache2配置文件 Require all granted是什么意思
  • c/c++ 的一些知识
  • Rancher上的应用服务报错:413 Request Entity Too Large
  • 【LeetCode题目详解】第八章 贪心算法 part01 理论基础 455.分发饼干 376. 摆动序列 53. 最大子序和 day31补
  • ssm+vue中国咖啡文化宣传网站源码和论文
  • 基于MATLAB开发AUTOSAR软件应用层Code mapping专题-part 4 Data store标签页介绍
  • 区间型动态规划典型题目:lintcode 476 · 石子归并【中等,免费】lintcode 593 · 石头游戏 II【中等 vip】
  • 4. 池化层相关概念
  • ChatGPT Prompting开发实战(一)
  • VB车辆管理系统SQL设计与实现
  • java 泛型
  • git 查看/配置 local/global 用户名称和用户邮箱
  • 无涯教程-分类算法 - 简介
  • python venv 打包,更换路径后,仍然读取到旧路径 ,最好别换路径,采用docker封装起来
  • MATLAB算法实战应用案例精讲-【自然语言处理】语义分割模型-DeepLabV3
  • road to master
  • <深度学习基础> 激活函数