C++基础入门---3.运算符【P16~P23】

博客主要介绍了多种运算符,包括算数运算符(加减乘除、取模、递增递减)、赋值运算符、比较运算符和逻辑运算符(非、与、或)。同时提到除法运算中除数不能为零,取模运算本质是取余数。

3. 运算符

在这里插入图片描述
在这里插入图片描述

3.1 算数运算符,加减乘除运算

注:在除法运算中,除数不能为零。

# include<iostream>
using namespace std;
int main()
{
	int a = 10;
	int b = 3;
	cout << a + b << endl;
	cout << a - b << endl;
	cout << a * b << endl;
	cout << a / b << endl;//两整数相除,结果依然是整数,将小数部分舍弃

	double c = 0.5;
	double d = 0.22;
	cout << c / d << endl;

	system("pause");
	return 0;
}

在这里插入图片描述

3.2 算数运算符,取模运算

注:取模运算的本质就是取余数。

#include<iostream>
using namespace std;
int main()
{
	int a = 10;
	int b = 3;

	cout << a % b << endl;
	//两小数不可以做取模运算

	system("pause");
	return 0;
}

3.3 算数运算符,递增递减

#include<iostream>
using namespace std;
int main()
{
	//前置递增
	int a = 10;
	++a;
	cout << " a= " << a << endl;
	//后置递增
	int b = 10;
	b++;
	cout << "b = " << b << endl;
	//前置递增,先让变量+1,然后进行表达式的计算
	int a1 = 10;
	int b1 = ++a1 * 10;
	cout << "a1= " << a1 << endl;
	cout << "b1= " << b1 << endl;

	//后置递增,先进行表达式的计算,再让变量+1
	int a2 = 10;
	int b2 = a2++ * 10;
	cout << "a2= " << a2 << endl;
	cout << "b2= " << b2 << endl;

	system("pause");
	return 0;
}

在这里插入图片描述

3.4 赋值运算符

在这里插入图片描述

# 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;
}

在这里插入图片描述

3.5 比较运算符

在这里插入图片描述

#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;

	system("pause");
	return 0;
}

3.6 逻辑运算符,非

在这里插入图片描述

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

3.7 逻辑运算符,与

#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;

	system("pause");
	return 0;
}

3.8 逻辑运算符,或

#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;
}
===== 待安装的HashData(postgresql14-libs-14.4-1KT)包信息 ===== 1. /opt/hashdata/HashData(postgresql14-libs-14.4-1KT)PGDG.rhel7.x86_64.rpm 2. /opt/hashdata/HashData(postgresql14-14.4-1KT)PGDG.rhel7.x86_64.rpm 3. /opt/hashdata/HashData(postgresql14-server-14.4-1KT)PGDG.rhel7.x86_64.rpm ======================================== ===== 安装HashData(postgresql14-libs-14.4-1KT) RPM包 ===== Last metadata expiration check: 0:05:04 ago on 2025年1113日 星期四 10时45分11. Error: Problem: problem with installed package paho-c-1.3.2-1.p05.ky10.x86_64 - package paho-c-1.3.2-1.p05.ky10.x86_64 requires libcrypto.so.1.1()(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p05.ky10.x86_64 requires libcrypto.so.1.1(OPENSSL_1_1_0)(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p05.ky10.x86_64 requires libssl.so.1.1()(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p05.ky10.x86_64 requires libssl.so.1.1(OPENSSL_1_1_0)(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.ky10.x86_64 requires libcrypto.so.1.1()(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.ky10.x86_64 requires libcrypto.so.1.1(OPENSSL_1_1_0)(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.ky10.x86_64 requires libssl.so.1.1()(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.ky10.x86_64 requires libssl.so.1.1(OPENSSL_1_1_0)(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p01.ky10.x86_64 requires libcrypto.so.1.1()(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p01.ky10.x86_64 requires libcrypto.so.1.1(OPENSSL_1_1_0)(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p01.ky10.x86_64 requires libssl.so.1.1()(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p01.ky10.x86_64 requires libssl.so.1.1(OPENSSL_1_1_0)(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p02.ky10.x86_64 requires libcrypto.so.1.1()(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p02.ky10.x86_64 requires libcrypto.so.1.1(OPENSSL_1_1_0)(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p02.ky10.x86_64 requires libssl.so.1.1()(64bit), but none of the providers can be installed - package paho-c-1.3.2-1.p02.ky10.x86_64 requires libssl.so.1.1(OPENSSL_1_1_0)(64bit), but none of the providers can be installed - cannot install both openssl-libs-1:1.0.2k-19.el7.x86_64 and openssl-libs-1:1.1.1f-31.p23.ky10.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p01.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p04.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p05.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p06.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p07.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p08.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p09.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p10.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p11.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p12.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p13.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p14.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p15.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p16.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p17.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p18.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p19.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p20.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p21.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p22.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p23.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - cannot install both openssl-libs-1:1.1.1f-4.p24.ky10.x86_64 and openssl-libs-1:1.0.2k-19.el7.x86_64 - package postgresql14-libs-14.4-1PGDG.rhel7.x86_64 requires libcrypto.so.10()(64bit), but none of the providers can be installed - package postgresql14-libs-14.4-1PGDG.rhel7.x86_64 requires libcrypto.so.10(libcrypto.so.10)(64bit), but none of the providers can be installed - package postgresql14-libs-14.4-1PGDG.rhel7.x86_64 requires libssl.so.10()(64bit), but none of the providers can be installed - package postgresql14-libs-14.4-1PGDG.rhel7.x86_64 requires libssl.so.10(libssl.so.10)(64bit), but none of the providers can be installed - conflicting requests (try to add &#39;--allowerasing&#39; to command line to replace conflicting packages or &#39;--skip-broken&#39; to skip uninstallable packages or &#39;--nobest&#39; to use not only best candidate packages) 安装 HashData(postgresql14-libs-14.4-1KT)PGDG.rhel7.x86_64.rpm 失败
最新发布
11-14
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值