![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法分析
蓝色水111
这个作者很懒,什么都没留下…
展开
-
求两个字符串的最长公共子序列
// 求两个字符串的最长公共子序列.cpp : 定义控制台应用程序的入口点。 #include "stdafx.h" #include #include #define N 10 using namespace std; void longest(string s1,string s2) { int i,j; int a[N][N]; for(i原创 2013-09-23 23:31:04 · 766 阅读 · 0 评论 -
求最大连续子序列乘积
// 求最大连续子序列乘积.cpp : 定义控制台应用程序的入口点。 //****************************动态规划方法******************************** #include "stdafx.h" #include #include int max(int x, int y, int z) { int temp = x>y?x:y;原创 2013-09-24 23:40:35 · 501 阅读 · 0 评论 -
求数组的子数组之和的最大值
// 求数组的子数组之和的最大值.cpp : 定义控制台应用程序的入口点。 #include "stdafx.h" #include using namespace std; //求数组的子数组之和的最大值为负时,直接返回0 int MaxSum(int * a, int n) { int sum=0; int b=0; sum = b = 0; for(int i=1; i<原创 2013-09-24 23:43:20 · 374 阅读 · 0 评论 -
求数组的最长递增子序列
// 求最长递增子序列.cpp : 定义控制台应用程序的入口点。 //动态规划思想 #include "stdafx.h" #include #include using namespace std; int dynamicProgram(int *arry,int n) { //list[i]存储着以arry[i]为最后一个元素的序列(该序列是递增子序列)的长度 int *list原创 2013-09-26 00:12:13 · 368 阅读 · 0 评论 -
输出任意多个序列的排列组合
// 输出任意多个序列的排列组合.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include #include #include #include #include #include using namespace std; int iResult[10]; static int iNum = 0; void solve( cons原创 2013-09-26 23:21:13 · 891 阅读 · 1 评论 -
删除一个字符串中连续的空格
// 删除一个字符串中连续的空格.cpp : 定义控制台应用程序的入口点。 // //问题描述:给定一个字符串,如果字符串中存在连续多个空格则用一个空格代替. //例如:输入:ab--cd-ef---g 输出:ab-cd-ef-g,为了方便,用-代替空格 //解决问题:写两个循环...第一个循环读到空格就使用第二个循环判断连续空格的数量.. //在第二个循环中一旦一个字符不是空格,就跳出本循环原创 2013-09-27 21:02:46 · 911 阅读 · 1 评论 -
判断一个单链表中是否有环
// 判断一个单链表中是否有环.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include //定义单链表的长度 const int length = 22; //定义单链表中环的起点 const int circularNum = 11; struct Node { int value; struct Node *next原创 2013-09-28 21:44:21 · 411 阅读 · 0 评论 -
输出链表中倒数第m个元素
// 输出链表中倒数第m个元素.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include #include struct Node { int value; struct Node *next; }; Node *createLinklist(int length) { Node *head, *last原创 2013-09-29 23:24:11 · 528 阅读 · 0 评论