// 以下几个单词,要记笔记int, 整型,用来存整数double, 双精度浮点型,用来存小数/实数char, 字符类型,用来存字符bool, 布尔类型,用来存true/falselong long, 长整型,用来存爆int的数,1e18这个量级的string, string类,用来存字符串的// 其他不常用的:short, 短整型float, 单精度浮点数
int,占4字节(Byte),取值范围 [-2^31, 2^31-1], 取值范围 [-2147483648, 2147483647] int n = (1ll << 31) - 1; cout << n << '\n';n++;cout << n << '\n';// 示例#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ int n = INT_MAX, m = INT_MIN; cout << n << '\n' << m << '\n'; return 0;}
long long, 取值范围[-9223372036854775808, 9223372036854775807]1e18级别的// 示例#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n = LLONG_MAX, m = LLONG_MIN; cout << n << '\n' << m << '\n'; return 0;}
// 关于占用存储空间的大小// 各个类型的变量长度由编译器来决定(实际上与操作系统位数和编译器都有关)// 使用时可用sizeof()得到// 当前主流编译器一般是32位或64位类型 32位 64位char 1 1char* 4 8short int 2 2int 4 4unsigned int 4 4long 4 8long long 8 8float 4 4double 8 8unsigned long 4 8
// 区间的符号// 区间 [1,5] 1,2,3,4,5 闭区间// 区间 (1,5) 2,3,4// 区间 (1,5] 2,3,4,5// 指数2^3 = 8// 单位换算1 Byte 8 bit1024 Byte 1 KB1024 KB 1 MB1024 MB 1 GB1024 GB 1 TB// 无符号整型unsigned int 无符号整型 4字节 [0, 4294967295]unsigned long long 8字节cout << (1 << 32) - 1 << '\n'; // 注意warning提示cout << (1ll << 32) - 1 << '\n';unsigned int n = (1ll << 33) - 1;n++;cout << n << '\n';// 关于有效位数的区分float 单精度浮点数 4字节 有效位数 6~7位double 双精度浮点数 8字节 有效位数 15~16位// 换行的操作cout << '\n'; 转义字符 换行/回车cout << endl;puts("");
// 输出占用存储空间的大小#include <iostream>using namespace std;int main(){ cout << sizeof(int) << '\n'; return 0;}
// 保留小数点后多少位的写法// 有效位数的区别#include <iostream>using namespace std;int main(){ double x = 1.0 / 3; printf("%.40lf\n", x); return 0;}// 0.3333333333333333148296162562473909929395
// 头文件的使用规则是需要使用什么头文件,就写什么头文件在使用DEV C++的时候,软件会默认带上一些头文件,这对新手来说,不是什么好事情基本的,你需要记住的是cin cout #include <iostream>scanf printf #include <cstdio>floor()这种函数 #include <cmath>sort()这个方法 #include <algorithm>// 万能头,是我们把语言部分比较熟练了之后,开始使用的,前期不应该使用,但要认识#include <bits/stdc++.h>
// 可能会在理解题意上出现stuck#include <cstdio>using namespace std;int main(){ int a, b; scanf("%d%d", &a, &b); printf("%.3lf%%\n", 1.0 * b / a * 100); return 0;}
// 多项式应该是一个超前知识点// 需要认识一下 x^3 是个啥#include <cstdio>using namespace std;int main(){ double x, a, b, c, d; scanf("%lf%lf%lf%lf%lf", &x, &a, &b, &c, &d); double ans = a * x * x * x + b * x * x + c * x + d; printf("%.7lf\n", ans); return 0;}
// 背景知识:物理,并联串联电阻// 适应一下这种题面,“新定义”#include <cstdio>using namespace std;int main(){ double r1, r2; scanf("%lf%lf", &r1, &r2); double r = 1.0 / (1 / r1 + 1 / r2); printf("%.2lf\n", r); return 0;}
// sizeof// 输出占用存储空间大小
// 百度ascii// 学会0-9 A-Z a-z// 学会大小写转化,字符和数字转化#include <bits/stdc++.h>using namespace std;int main(){ char c; scanf("%c", &c); printf("%d\n", c); return 0;}
// 理解一下余数的定义
// v = 4/3 * PII * r^3// 需要注意整数除整数的问题
#include <iostream>using namespace std;int main(){ int x; cin >> x; cout << x % 10 << x / 10 % 10 << x / 100 << '\n'; return 0;}// 拓展:给定一个数n,翻转得到新的数字n`,输出 n + n` 的值
// 这道题PII取3.14即可// 注意问题的实际背景,需要整桶整桶的水// 如果不知道圆柱体的体积,可以百度