上一页 1 ··· 3 4 5 6 7 8 下一页
摘要: 1.https://www.acwing.com/problem/content/431/ 主要是重载小于号和自己写比较函数两种方法,但是之前不会 现在会了就好 ####重载小于号 1 #include <iostream> 2 #include <algorithm> 3 #include <cs 阅读全文
posted @ 2021-11-20 22:43 乐池 阅读(56) 评论(0) 推荐(0)
摘要: 1.链表 1)单链表:邻接表 数组实现单链表: #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int N = 100010; //e[N 阅读全文
posted @ 2021-11-17 21:12 乐池 阅读(34) 评论(0) 推荐(0)
摘要: 1.双指针 2.位运算 3.离散化 1)去除重复元素 vector<int>all; sort(all.begin() , all.end());//排序 all.erase(unique(all.begin() , all.end()) , all.end());//删除末尾的重复元素 2)代码 阅读全文
posted @ 2021-11-17 00:16 乐池 阅读(35) 评论(0) 推荐(0)
摘要: 1.快速排序:基本思想是分治,时间复杂度nlog(n) 1)确定分界点 2)调整区间 3)递归处理左右两段 #include <iostream> #include <cstdio> using namespace std; const int N = 100010; int a[N]; void 阅读全文
posted @ 2021-11-13 12:00 乐池 阅读(30) 评论(0) 推荐(0)
摘要: 1.位运算 & 与 AND | 或 OR ~ 非 NOT ^ 异或 XOR >> 右移 << 左移 求x的第k位数字 x >> k & 1 , 从后往前数,最末一位是0 lowbit(x) = x & -x,-x是(~x+1) ; 返回x的最后一位1 , 即110110,则返回10 ; 101000 阅读全文
posted @ 2021-11-11 19:36 乐池 阅读(67) 评论(0) 推荐(0)
摘要: 1.vector 头文件#include <vector> 常见的方法有vector.clear() ; vector.size() ; vector.empty(); 遍历输出vector: #include <iostream> #include <vector> using namespace 阅读全文
posted @ 2021-11-10 18:20 乐池 阅读(58) 评论(0) 推荐(0)
摘要: 1.类的定义 在类的大括号后面要加分号。 private:加私有的变量,方法等 public:加公开的变量方法等 类的调用:直接写类的名字就行 2.结构体和类 在类中没有声明是private还是public则默认为private,class count 在结构体中默认为pubic,struct co 阅读全文
posted @ 2021-11-08 23:10 乐池 阅读(127) 评论(0) 推荐(0)
摘要: 1.跳台阶 一个楼梯共有 nn 级台阶,每次可以走一级或者两级,问从第 00 级台阶走到第 nn 级台阶一共有多少种方案。 输入格式 共一行,包含一个整数 nn。 输出格式 共一行,包含一个整数,表示方案数。 数据范围 1≤n≤15 输入样例: 5 输出样例: 8 用递归写,代码: #include 阅读全文
posted @ 2021-11-08 22:22 乐池 阅读(44) 评论(0) 推荐(0)
摘要: 1.静态变量,指某个变量只会创建一次,static 调用5次count方法,而n只会被定义一次0,所以输出的n并不会一直是1 2.函数调用赋值 此时a和b的值都不会变化,但是在被引用的函数添加上取地址符号就不一样了 3.数组参数调用 一维数组能省略数组的大小,多维数组只能省第一个 代码: 给定一个数 阅读全文
posted @ 2021-11-06 19:31 乐池 阅读(38) 评论(0) 推荐(0)
摘要: 2.1水仙花数 输出100~999中的所有水仙花数。若3位数ABC满足ABC = A^3+B^3+C^3,则称其为水仙花数。 #include <iostream> using namespace std; int main(){ for(int j = 1;j<=9;j++){ for(int k 阅读全文
posted @ 2021-11-06 14:34 乐池 阅读(52) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 下一页