摘要: 折半查找,这个非常简单 #include <iostream> using namespace std; // 折半查找 int Binary_search(int a[], int len, int key) { int low = 0, high = len - 1, mid; while (l 阅读全文
posted @ 2021-03-17 23:08 adamweng 阅读(189) 评论(0) 推荐(0)
摘要: 堆排序: #include <iostream> using namespace std; // 建大根堆 void Heap_build(int a[], int root, int len) { int lchild = root*2 + 1; if (lchild < len) { int f 阅读全文
posted @ 2021-03-17 22:44 adamweng 阅读(53) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; // 冒泡排序 (和鱼冒泡泡一样,从底部往水面冒) void BubbleSort(int A[], int n) { int i, j; // 冒泡中两层循环用到 bool flag; // 判断排序是否结束 for 阅读全文
posted @ 2021-03-17 00:02 adamweng 阅读(68) 评论(0) 推荐(0)