摘要: 1 #include <iostream> 2 #include <cstdlib> 3 #include <cstdio> 4 #include <cstring> 5 #include <string> 6 #include <vector> 7 #include <iterator> 8 #i 阅读全文
posted @ 2020-11-24 20:44 ctxcc 阅读(189) 评论(0) 推荐(0)
摘要: n个操作 I: 插入一个数 PM:输出最小值 D k:删除第k个插入的数 C k x:将第k个插入的数的值改成x DM:删除最小值 CODE: ph[k]:第k个插入的数的下标 hp[i]:下标为i是第k个插入的数 const int N = 100010; int n, m, h[N], size 阅读全文
posted @ 2020-11-16 21:06 ctxcc 阅读(105) 评论(0) 推荐(0)
摘要: typedef struct node *pos; typedef struct node *AvlT; struct node { int val; AvlT l; AvlT r; int h; }; static int Height(pos p) { if (!p) return -1; re 阅读全文
posted @ 2020-11-01 21:49 ctxcc 阅读(116) 评论(0) 推荐(0)
摘要: #include <iostream>#include <cstring>#include <string>#include <vector>#include <iterator>#include <stack>#include <cstdlib> using namespace std; cons 阅读全文
posted @ 2020-10-30 20:41 ctxcc 阅读(138) 评论(0) 推荐(0)
摘要: find、insert、delete、先序遍历操作 typedef struct node stree; struct node { int val; stree *left; stree *right; }; stree *T; stree* MakeEmpty(stree *t) { if (t 阅读全文
posted @ 2020-10-29 20:50 ctxcc 阅读(117) 评论(0) 推荐(0)
摘要: 题目:啊哈算法 P114 求有多少个独立小岛 其中陆地点大于0,海洋点为0 int mp[N][N], book[N][N]; int n, m; // n * m地图 int num = 0;int divv[4][2] = {{0,1},{1,0},{0,-1},{-1,0}};void dfs 阅读全文
posted @ 2020-10-09 16:24 ctxcc 阅读(84) 评论(0) 推荐(0)
摘要: · static局部静态变量:同全局变量都是:默认初始化0 程序终止才销毁 · 分离式编译:假设fact函数的定义位于一个名为fact.cc的文件,它的声明位于Chapter6.h头文件。显然与其他所有用到fact函数的文件一样,fact.cc应该包含Chapter6.h头文件 · 含有可变形参的函 阅读全文
posted @ 2020-09-29 22:05 ctxcc 阅读(92) 评论(0) 推荐(0)
摘要: · 不可在switch内部定义变量: 因为程序的执行流程可能绕开该初始化语句,所以不合法 case true: eng'xing int jval = 0; 但可以在块内定义 case true: { int jval = 0; } · case标签必须是常量表达式 · 定义在while条件部分或循 阅读全文
posted @ 2020-09-29 21:47 ctxcc 阅读(94) 评论(0) 推荐(0)
摘要: · decltype: ① decltype(*p)的结果是 int& ② decltype(&p)的结果是 int** (一个指向整型指针的指针) · bool不该参与运算:bool b = true; bool b2 = -b; // b2为true · 整数才可取模%,浮点型不可以 · 负数取 阅读全文
posted @ 2020-09-22 21:35 ctxcc 阅读(115) 评论(0) 推荐(0)
摘要: · 头文件不应包含using声明:若某文件中使用了多个头文件(含using声明) 产生冲突 · string s; cin >> s; string对象读取时自动忽略开头的空白(空格符、换行符、制表符等) 并从第一个真正的字符读起,直到遇见下一处空白为止 · getline:可以读取空白符,直到遇到 阅读全文
posted @ 2020-09-22 20:59 ctxcc 阅读(128) 评论(0) 推荐(0)