#include <bits/stdc++.h>
using namespace std;
int main() {
// 1. 基本数据类型
// (1) 整型数据类型
// int 整型 (4个字节): -21亿 ~ 21亿 (10位数字)
// long long 超长整型 (8个字节): -922亿亿 ~ 922亿亿 (19位数字)
long long a, b;
cin >> a >> b;
cout << a + b << endl;
// char 字符型 (1个字节) :-128 ~ 127
char c = 'A' + 15;
cout << c << endl;
cout << int(c) << endl;
// bool 逻辑型 (1个字节) :-128 ~ 127
int n;
cin >> n;
bool flag = (n == 100); // true : 1, false : 0
cout << flag << endl;
// (2) 浮点数据类型
// 123.456 : 0.123456 x 10的3次方
// float 单精度 (4个字节): 7位有效数字,正负10的38次方
// double 双精度 (8个字节): 17位有效数字,正负10的109次方
double db = 1.0 * 10 / 3 ;
cout << db << endl;
cout << fixed << setprecision(14) << db << endl;
// 2. 变量、常量
// (1) 变量
int n;
char c;
// (2) 常量
const double pi = 3.1415926535897932;
//pi = 3.14;
cout << pi << endl;
// 3. 运算符
// (1) 算术运算符: + - * / %
double R = 1.0 / (1.0 / r1 + 1.0 / r2)
cout << pow(2, 3) << endl; // 乘方
cout << sqrt(16) << endl; // 算术平方根
cout << cbrt(8) << endl; // 算术立方根
cout << abs(-10) << endl; // 整数绝对值
cout << fabs(-8.3) << endl; // 浮点数绝对值
cout << ceil(1.32) << endl; // 向上取整
cout << floor(1.82) << endl; // 向下取整
cout << int(1.82) << endl; // 向下取整
cout << round(3.45) << endl; // 四舍五入取整
cout << ceil(-1.32) << endl; // 向上取整
cout << floor(-1.82) << endl; // 向下取整
cout << int(-1.82) << endl; // 向下取整
cout << round(-3.45) << endl; // 四舍五入取整
cout << round(3.433 * 100) / 100 << endl;
cout << fixed << setprecision(2) << 3.433 << endl;
// 2. 关系运算符 > , >= , <, <=, ==, !=
int n;
cin >> n;
if (!(n > 0)) {
cout << "真 true 成立" << endl;
} else {
cout << "假 false 不成立" << endl;
}
// 3. 逻辑运算符: 逻辑与 &&, 逻辑或 ||, 逻辑非 !
// n > 0 && n < 100 (相当于 0 < n < 100)
// n < 0 || n > 100 (相当于 n < 0, 或 n > 100)
// !(n > 0) (相当于 非正数)
return 0;
}
点击打开老师的博客