
分治法
0000000
「已注销」
这个作者很懒,什么都没留下…
展开
-
快速排序递归实现
#include<iostream> using namespace std; int *s; void Swap(int pos1,int pos2){ int temp = s[pos1]; s[pos1] = s[pos2]; s[pos2] = temp; } int Patition(int left,int right){ int i = left,j = right + 1; int temp = s[left]; while(true){ while(s[++i.原创 2020-11-05 21:29:13 · 126 阅读 · 0 评论 -
归并排序(递归 + 非递归)
#include<iostream> using namespace std; void Merge(int *s,int *temp,int left,int mid,int right){ int lp = left; int rp = mid + 1; int k = 0; while(lp <= mid && rp <= right){ if(s[lp] <= s[rp])temp[k++] = s[lp++]; else temp[k.原创 2020-11-05 17:40:10 · 186 阅读 · 0 评论 -
二分法查找(折半查找)【有序表快速查找】
#include<iostream> #include<algorithm> using namespace std; int g[20],index,n; int Bisearch(int left,int right){ int mid = (left + right)/2; if(right < left)return -1; if(g[mid] == index)return mid; else{ if(g[mid] > index)Bisearch.原创 2020-10-31 17:33:19 · 807 阅读 · 0 评论 -
棋盘覆盖(分治法)
#include<iostream> #include<cstdio> #define MAX_SUM 16 using namespace std; int tile = 0; int Board[MAX_SUM][MAX_SUM]; void Initial(int &size,int &dr,int &dc){ cout<<"please input the size , dr and dc"<<endl; cin>&.原创 2020-11-04 18:12:29 · 236 阅读 · 0 评论