- 博客(9)
- 资源 (2)
- 收藏
- 关注
原创 通过前序和中序重建二叉树
#include #include #include using namespace std; struct Node{ char val; Node * l; Node * r; }; int indexOf(const char * str,char val,int size) { int i=0; for(i=0;i<size;i++) { if(str[i]==v
2014-09-07 17:03:57 106
原创 算法导论动态规划算法的实现(带备忘的自定而下)
#include using namespace std; int map[11]={0,1,5,8,9,10,17,17,20,24,30}; int max(int a,int b) { return (a>b?a:b); } bool flag[1000]; int rom[1000]; int cut(int n) { if(flag[n]) return rom[n]; fl
2014-05-18 20:02:00 164
原创 BellFord单元最短路径算法
#include #include #define maxnum 1000 #define edgemax 2000; using namespace std; int edges; int node[maxnum]; int nodenum; struct edge { int value; int a; int b; //a to b is edge }; edge e[maxn
2014-04-24 11:49:14 299
原创 快速排序算法
#include #include #include using namespace std; void swap(int *a,int*b) { int temp =*a; *a=*b; *b=temp; } int random(int st,int end) { int length = end-st+1; return st+rand()%length; } int
2014-04-18 10:31:16 130
原创 归并排序
#include using namespace std; //st1->end 和end+1->到n这两个数列的归并算法 void merge(int * data,int st1,int end,int endend) { int length1= end-st1+1; int length2= endend-end; int* L = new int[length1]; int
2014-04-18 10:19:41 84
原创 c++的堆排序
#include using namespace std; void swap(int * a,int *b); void AdjustHeap(int data[],int start,int end) { int j=2*start+1; //int temp=data[start]; while(j { if(j==3) ; if(data[j] if(data[
2014-04-17 22:06:03 127
原创 剑指offer查找二叉树中的子树结构
#include using namespace std; struct node { char value; node * lchild; node * rchild; }; node * create() { node * pnode=NULL; char t; cin>>t; if(t=='#') return NULL; else { pnode = (node
2014-04-17 11:02:16 114
原创 基于广度搜索的最短路路径
#include #include #define max 1001 using namespace std; int map[max][max]; bool visited[max]; int num; struct node { int value; node * pre; }; int getFirst(int v) { int i=0; for(i=1;i<num;i++) {
2014-04-16 19:52:05 153
原创 链表的创建和反转
#include using namespace std; struct node{ int value; node * next; }; node * CreatNodeList() { int num; cin>>num; node * head =(node *)malloc(sizeof(node)); head->value = 0; node * temp = h
2014-04-07 17:17:58 151
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人