摘要: //最大子序列和(连续)://http://my.oschina.net/itblog/blog/267860#include using namespace std;int MaxSum(int* a, int n){ int sum = 0; int max = 0; //... 阅读全文
posted @ 2015-05-25 14:13 M_Kepler 阅读(258) 评论(0) 推荐(0) 编辑
摘要: //最短路径/*dijkstraDijkstra(迪杰斯特拉)算法的核心思想是贪心策略+动态规划http://www.programgo.com/article/4721147659/Dijkstra算法能得出最短路径的最优解,但是效率低*/Floyed 算法: Floyed算法比较简单,其思想可... 阅读全文
posted @ 2015-05-25 13:47 M_Kepler 阅读(414) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;string a,b;int dp[505][505];int main(){ while(cin>>a>>b) { int len1=a.length(); int len2=b.len... 阅读全文
posted @ 2015-05-24 23:05 M_Kepler 阅读(211) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;#include void lcs(int **A,const string &x,const string &y){ int m=x.size(); int n=y.size(); if(m=A[m][n-1]) ... 阅读全文
posted @ 2015-05-22 21:07 M_Kepler 阅读(210) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;typedef int DataType;struct SeqList{ int MAXNUM; int n; DataType *element;};typedef struct SeqList *PSeqList;PSe... 阅读全文
posted @ 2015-05-21 22:42 M_Kepler 阅读(344) 评论(0) 推荐(0) 编辑
摘要: //链表:#include using namespace std;//定义结点:struct NODE{ int data;//数据域 NODE *next;//指针域};//链表类:class LIST{ NODE *head;public: //构造函数 LIST... 阅读全文
posted @ 2015-05-20 22:24 M_Kepler 阅读(257) 评论(0) 推荐(0) 编辑
摘要: #include #include typedef struct PolyNode *PtrToNode; //定义链表节点,也就是多项式中的某一项; typedef struct PolyNode { int Coeff; int Exponent; PtrToNo... 阅读全文
posted @ 2015-05-19 20:17 M_Kepler 阅读(418) 评论(0) 推荐(0) 编辑
摘要: //二叉树#include#include#includeusing namespace std;//二叉树结点typedef struct BiTNode{ char data; struct BiTNode *lchild,*rchild;}BiTNode,*BiTree;//按先序... 阅读全文
posted @ 2015-05-15 23:06 M_Kepler 阅读(198) 评论(0) 推荐(0) 编辑
摘要: //DFS:油田问题#include using namespace std;char grid[101][101];int n,m;//一个网格的8个方向int dir[8][2] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}... 阅读全文
posted @ 2015-05-10 20:47 M_Kepler 阅读(427) 评论(0) 推荐(0) 编辑
摘要: 一、一个数组里除了一个数字之外,其他的数字都出现了两次 用异或来解#include using namespace std;int main(){ int T; int n,m; while(cin>>T,T){ cin>>n; while... 阅读全文
posted @ 2015-04-28 21:35 M_Kepler 阅读(239) 评论(0) 推荐(0) 编辑