2012年6月3日

摘要: View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#define MAX 26typedef struct Node{ int isword; struct Node *next[MAX];}Trie;void InsertTree(Trie *root,const char *s);int searchTree(Trie *root,const char *s);void deleteTree(Trie *root);void InsertTree(Trie *root,co 阅读全文
posted @ 2012-06-03 21:49 蓝色守望 阅读(178) 评论(0) 推荐(0)
摘要: View Code #include <stdio.h>void perfix(char P[],int U[],int lenP);void match(char T[],char P[],int U[],int lenT,int lenP);void perfix(char P[],int U[],int lenP){ U[0]=-1; int k=-1; int i=1; for(;i<lenP;i++){ while(P[k+1]!=P[i]){ if(k==-1) break; k=U[k]; ... 阅读全文
posted @ 2012-06-03 13:25 蓝色守望 阅读(153) 评论(0) 推荐(0)
摘要: 动态规划的主旨是以空间换时间,就是为了避免重复计算,把第一次计算的结果保存起来。最优子结构是使用动态规划的标志之一;另一个标志是子问题的重叠性。动态规划其实就是一个动态的递归,一个递归式和一个终止条件。 阅读全文
posted @ 2012-06-03 10:15 蓝色守望 阅读(250) 评论(0) 推荐(0)

2012年5月31日

摘要: 今天下午把字符数组和字符串搞错了。int a[3]={1,2,3},居然用strlen(a)来求数组的长度。int strlen(const char *s)参数接受的是字符串。char s[4]="abc"。不是字符串(没有通常的字符串终止符'\0',因此所有对字符串进行处理的函数,比如strcpy、printf等,都不能够被使用在这个假字符串上),而是字符数组的一种快速初始化方式,末尾是一个隐含的字符''\0",用来判断是否到字符串末尾。char c[3]={'a','b','c' 阅读全文
posted @ 2012-05-31 19:06 蓝色守望 阅读(149) 评论(0) 推荐(0)

2012年5月29日

摘要: #include <stdio.h>int Pation(int ch[],int begin,int end);void Sort(int ch[],int begin,int end){ if(begin<end){ int mid=Pation(ch,begin,end); Sort(ch,begin,mid-1); Sort(ch,mid+1,end); }}int Pation(int ch[],int begin,int end){ int tmp=ch[end]; int i=begin-1; int j=b... 阅读全文
posted @ 2012-05-29 21:14 蓝色守望 阅读(104) 评论(0) 推荐(0)
摘要: typedef int ElemType;typedef struct Binary_Tree{ ElemType value; int bf ; struct Binary_Tree *lchild,*rchild;}Tree;void InsertTree(Tree **t,ElemType e){ Tree *node; node=*t; if(!node){ node=(Tree *)malloc(sizeof(Tree)); node->value=e; node->lchild=NULL; node->rchild=NULL; *t=node; } else i. 阅读全文
posted @ 2012-05-29 17:00 蓝色守望 阅读(198) 评论(0) 推荐(0)

2012年5月25日

摘要: 在C中内存,可以划分为三种,堆、栈和静态存储区。栈就是auto变量存放区域,自动释放,在编译时候需要知道空间大小。堆一般用作开辟动态存储区,需要人工开辟,人工释放,可以在运行是开辟。比如说c中的malloc和free函数,还有C++中的new和delete。还有就是静态存储区,这个区域存放一些常量,不能改变值。char *a="I love zhong wanjing";和char a[]="I love zhong wanjing";第一个是字符串在静态存储区存储,a是定义在栈,是一个“远程指向”,不能对 *a进行重新赋值,但是可以通过改变a指向的地址 阅读全文
posted @ 2012-05-25 12:05 蓝色守望 阅读(142) 评论(0) 推荐(0)

导航