03 2017 档案

广义表的实现(法二)
摘要:#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 阅读(506) 评论(0) 推荐(0)

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

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

有错误的地宫寻宝问题
摘要://虽然有错误,但此程序可以看出多个递归式放在一起的情况#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 阅读(186) 评论(0) 推荐(0)

写一个数的所有加法算式
摘要:#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 阅读(269) 评论(0) 推荐(0)

将字符串中的星号去掉
摘要:#include "iostream.h" #include "string.h" void main() { char a[]="******ab**c*****d*efgh****k***"; int i=0,starCnt=0; while (a[i]=='*') i++; while (a[i]!='\0') { if(a[i]==... 阅读全文

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

一个序列出现固定元素个数的方法(DFS)
摘要:#include int a[100];int i; static int stat=0; void dfs(int n,int oneCount) { if(oneCount>2||n==3&&oneCount!=2) return ; if(n==3&&oneCount==2) { for (i=0;i<n;i++) ... 阅读全文

posted @ 2017-03-23 20:35 ewitt 阅读(225) 评论(0) 推荐(0)

多项式相加(顺序表)
摘要:#include typedef struct { int coef; int index; }datatype ; typedef struct { datatype *elem; int length; }SeqList; void BuildPoly(SeqList &s) { s.elem=new datatype[10]; s.len... 阅读全文

posted @ 2017-03-13 13:03 ewitt 阅读(1612) 评论(1) 推荐(0)

组合(n选k问题)
摘要:#include "iostream.h" #include "string.h" int a[100]; void dfs(int n,int k) { if (k==0) { for (int i=1;i=k;i--) { a[k]=i; dfs(i-1,k-1); } } void main() { m... 阅读全文

posted @ 2017-03-13 12:59 ewitt 阅读(149) 评论(0) 推荐(0)

数学算式搜索问题
摘要:#include "iostream.h" #include "string.h" #include "math.h" float a[9]; bool repeat(int i) { for(int k=0;k<i;k++) if(a[k]==a[i]) return 1; return 0; } void dfs(int n) { ... 阅读全文

posted @ 2017-03-09 09:47 ewitt 阅读(136) 评论(0) 推荐(0)

n皇后问题
摘要:#include "iostream.h" #include "string.h" #include "math.h" const int col=4;//4 columns int r[col];//r[i]represents for the r[i]-th column of i-th row bool fit(int row) { for (int i=0;i<row ;i++... 阅读全文

posted @ 2017-03-09 09:29 ewitt 阅读(81) 评论(0) 推荐(0)

linklist template
摘要:#include typedef int ElemType; typedef struct LNode { ElemType data; struct LNode *next; }LNode; void CreateList(LNode *&L,int a[],int n) { LNode *p; L=new LNode; L->next=... 阅读全文

posted @ 2017-03-03 15:52 ewitt 阅读(222) 评论(0) 推荐(0)

seqlist template
摘要:1 #include 2 typedef int ElemType; 3 typedef struct{ 4 ElemType *elem; 5 int length; 6 }SeqList; 7 8 void InitSeq(SeqList &L,int n,ElemType a[]) 9 { int i=0; 10 L.elem=new ElemTy... 阅读全文

posted @ 2017-03-03 15:40 ewitt 阅读(289) 评论(0) 推荐(0)

导航