2017年5月23日

Heap Sort

摘要: #include #define N 8 int a[]={0,39,21,40,92,29,11,32,9}; void Adjust(int i,int last) { int k=2*i; int t=a[i],tag=1; while(ka[k+1]) k++; if(t>a[k]) { a[i]=a[k]; i=k; k=2*i; ... 阅读全文

posted @ 2017-05-23 20:29 ewitt 阅读(134) 评论(0) 推荐(0)

2017年5月9日

Hash表

摘要: #include "iostream.h" #include "fstream.h" #include "string.h" #define MaxLen 13 #define Div 11//被除数 typedef struct node { char name[20]; int age; bool tag; }addrBook; addrBook *bk=n... 阅读全文

posted @ 2017-05-09 21:47 ewitt 阅读(137) 评论(0) 推荐(0)

2017年5月3日

hanoi(老汉诺塔问题新思维)

摘要: 此解用于讲解原问题与子问题之间能建立合适的关系即可,无需要非要让n阶问题与n-1阶问题产生关系。 n阶问题与其子问题n-2阶问题如下图所示: 阅读全文

posted @ 2017-05-03 14:46 ewitt 阅读(226) 评论(0) 推荐(0)

2017年4月27日

prim算法

摘要: #include #include using namespace std; #define MAX 5 #define INF 32765 int AdjMtx[MAX][MAX]= {{INF ,1,INF,4,3}, {1,INF,2,INF,INF}, {INF,2,INF,2,3}, {4,INF,2,INF,1}, {3,INF,3,1,INF}}; int lowcost[... 阅读全文

posted @ 2017-04-27 21:57 ewitt 阅读(151) 评论(0) 推荐(0)

2017年4月25日

Kruscal algorithm

摘要: #include #include using namespace std; #define MAX 5 #define INF 32765 int graph[MAX][MAX]= {{INF ,1,INF,4,3}, {1,INF,2,INF,INF}, {INF,1,INF,2,3}, {4,INF,2,INF,1}, {3,INF,3,1,INF}}; typedef struct... 阅读全文

posted @ 2017-04-25 15:56 ewitt 阅读(164) 评论(0) 推荐(0)

2017年4月6日

递归程序设计思想(看图思考2小时)

摘要: 递归程序设计思想: 1、原问题是如何由子问题解决的;(即原问题与子问题的递归关系) 2、子问题与原问题的解决方案是否一模一样。 阅读全文

posted @ 2017-04-06 21:28 ewitt 阅读(189) 评论(0) 推荐(0)

2017年3月30日

广义表的实现(法二)

摘要: #include #include using namespace std; enum elemTag {ATOM,LIST}; class GList; class GLnode { private: elemTag Tag; //标志是原子还是子表 0:原子 1:子表 union { char data; //原子结点值域 st... 阅读全文

posted @ 2017-03-30 21:40 ewitt 阅读(496) 评论(0) 推荐(0)

广义表的实现

摘要: /*--------------------------------------------------------------------- 广义表的存储结构 ---------------------------------------------------------------------*/ #include #include typedef char ElemTy... 阅读全文

posted @ 2017-03-30 21:37 ewitt 阅读(2660) 评论(0) 推荐(0)

2017年3月27日

有错误的地宫寻宝问题

摘要: //虽然有错误,但此程序可以看出多个递归式放在一起的情况#include using namespace std; static int count=0; int x,y; int m,n,k; int a[50][50]; int t=0; void dfs(int x,int y,int s,int t) { if(x>m || y>n || s>k) ... 阅读全文

posted @ 2017-03-27 18:28 ewitt 阅读(175) 评论(0) 推荐(0)

2017年3月26日

写一个数的所有加法算式

摘要: #include #include int a[100]; void dfs(int rem,int prior,int i)//rem->remainder,i->the i-th number { if(rem=1) cout=1;j--) //the following value is less than of equal the prior {a[i]=j;... 阅读全文

posted @ 2017-03-26 19:14 ewitt 阅读(253) 评论(0) 推荐(0)

导航