摘要: 从一个结点开始DFS,BFS生成树#include<iostream>#include<fstream>#include<string>using namespace std;#define MAX 40#define Null 0int visited[MAX]; //0表示未访问,1表示已经访问ofstream out("DFS.txt"); typedef... 阅读全文
posted @ 2009-07-22 10:56 Forgetting 阅读(163) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;#define Stack_Init_Size 100#define StackIncrement 10#define NULL 0typedef struct BiTNode{char data;struct BiTNode *lchild,*rchild;}BiTNode,*BiTree;typedef s... 阅读全文
posted @ 2009-07-22 10:55 Forgetting 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 递归方法:#include<iostream>using namespace std;#define NULL 0typedef struct BiTNode{char data;struct BiTNode *lchild,*rchild;}BiTNode,*BiTree;void CreateBiTree(BiTree &T){char ch;ch=getchar();if... 阅读全文
posted @ 2009-07-22 10:54 Forgetting 阅读(186) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<fstream>#define MAX 40#define Null 0int visited[MAX]; //0表示未访问,1表示已经访问using namespace std;typedef struct ArcNode{int adjvex; //该弧所指向的顶点的位置 struct ArcNode *nextar... 阅读全文
posted @ 2009-07-22 10:51 Forgetting 阅读(388) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;#define Stack_Init_Size 100 //存储空间初始化分配量#define Stack_Increment 10 //存储空间分配增量#define error 0 typedef struct{float *base; float *top; //栈里的所有数据都是以float型存储的 i... 阅读全文
posted @ 2009-07-22 10:50 Forgetting 阅读(263) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;typedef struct{unsigned int weight;unsigned int parent,lchild,rchild;}HTNode,*HuffmanTree; //动态分配数组存储赫夫曼树typedef char **HuffmanCode; //动态分配数组存储赫夫曼编码表void Se... 阅读全文
posted @ 2009-07-22 10:48 Forgetting 阅读(437) 评论(0) 推荐(0) 编辑
摘要: 问题描述: 已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围。从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列。 顺序结构:#include<iostream>#include<vector>using namespace std;int man,password,nex... 阅读全文
posted @ 2009-07-22 10:47 Forgetting 阅读(479) 评论(0) 推荐(0) 编辑
摘要: Broken NecklaceYou have a necklace of N red, white, or blue beads (3<=N<=350) some of which are red, others blue, and others white, arranged at random. Here are two examples for n=29: 1 2 1 2 r ... 阅读全文
posted @ 2009-07-22 10:16 Forgetting 阅读(280) 评论(0) 推荐(0) 编辑
摘要: Greedy Gift GiversA group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the o... 阅读全文
posted @ 2009-07-22 10:14 Forgetting 阅读(254) 评论(0) 推荐(0) 编辑