随笔分类 - C++
关于C++的学习和使用C++完成一些算法
摘要:折半查找,这个非常简单 #include <iostream> using namespace std; // 折半查找 int Binary_search(int a[], int len, int key) { int low = 0, high = len - 1, mid; while (l
阅读全文
摘要:堆排序: #include <iostream> using namespace std; // 建大根堆 void Heap_build(int a[], int root, int len) { int lchild = root*2 + 1; if (lchild < len) { int f
阅读全文
摘要:#include <iostream> using namespace std; // 冒泡排序 (和鱼冒泡泡一样,从底部往水面冒) void BubbleSort(int A[], int n) { int i, j; // 冒泡中两层循环用到 bool flag; // 判断排序是否结束 for
阅读全文
摘要:#include <iostream> using namespace std; // 计算Next数组 void makeNext(const char p[], int next[]) { int q, k; // q是字符串下标,k是最大公共前缀 int m = strlen(p); next
阅读全文
摘要:准备杭电复试,想着把数据结构相关的算法都自己写一遍,个人记录为主,带注释。 代码: #include <iostream> using namespace std; void quickSort(int a[], int low, int high) { int temp; //放枢轴的变量 int
阅读全文

浙公网安备 33010602011771号