![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
连卡佛哈利
如风飞掠,不可回望,还是一路向前吧!
展开
-
Ackerman
第二篇—阿克曼函数#include<stdlib.h>#include<iostream>using namespace std;int Ackerman(int n, int m) { if (m == 0 && n == 1) return 2; if (m >= 0 && n == 0)return 1; if ...原创 2019-09-16 16:58:21 · 184 阅读 · 0 评论 -
二分搜索的递归实现
第三篇—二分搜索#include<iostream>#include<stdlib.h>using namespace std;int Binarysearch(int a[], int left,int right,int n) { if(left <= right) { int middle = (left + right) / 2; if ...原创 2019-09-16 17:01:48 · 198 阅读 · 0 评论 -
斐波那契数列
#include<iostream>#include<stdlib.h>using namespace std;int F[100] = { 0 };int f[100] = { 0 };//斐波那契数列自底向上非递归动态规划int Fibonacci(int n) { F[0] = 1; F[1] = 1; for (int i = 2; i &l...原创 2019-09-16 17:06:17 · 129 阅读 · 0 评论 -
合并排序递归实现
第五篇—合并排序递归实现#include<iostream>#include<stdlib.h>using namespace std;int a[10] = { 5,7,4,2,9,3,10,8,1,4};int b[10] = { 0 };void Merge(int a[], int b[], int left, int middle, int ri...原创 2019-09-16 17:10:10 · 324 阅读 · 0 评论 -
活动安排贪心算法
第六篇—活动安排贪心算法#include<iostream>#include<stdlib.h>using namespace std;int n = 11;int s[11] = {1,3,0,5,3,5,6,8,8,2,12};int f[11] = {4,5,6,7,8,9,10,11,12,13,14};bool A[11] = {false};...原创 2019-09-16 17:11:51 · 267 阅读 · 0 评论 -
矩阵连乘
#include<stdlib.h>#include<iostream>#define N 6using namespace std;int m[N+1][N+1];//最优值int s[N+1][N+1];//记录断开点位置int p[N + 1] = {30,35,15,5,10,20,25};//第1、2、3、4、5、6个矩阵行数,第6个矩阵列数.voi...原创 2019-09-16 17:16:12 · 228 阅读 · 0 评论 -
快速排序的递归实现
第八篇–快速排序的递归实现#include<iostream>#include<stdlib.h>using namespace std;int a[5] = { 2,1,7,4,9 };void Swap(int a[],int i ,int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp;}int...原创 2019-09-16 17:17:59 · 178 阅读 · 0 评论 -
整数划分的递归实现
第九篇—整数划分#include<iostream>#include<stdlib.h>using namespace std;int q(int n, int m) { if (n < 1 && m < 1) return 0; if (n == 1 || m == 1) return 1; if (n < m)...原创 2019-09-16 17:20:15 · 124 阅读 · 0 评论 -
动态规划之最大字段和
第十篇—最大字段和#include<stdlib.h>#include<iostream>#define N 6using namespace std;int a[6] = { -2,11,-11,13,-2,5 };int MaxSum() {//动态规划之最大字段和 int sum = 0, b = 0; for (int i = 0; i &l...原创 2019-09-16 17:21:46 · 416 阅读 · 1 评论