2017年3月26日

将字符串中的星号去掉

摘要: #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 阅读(3025) 评论(0) 推荐(0)

2017年3月23日

一个序列出现固定元素个数的方法(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 阅读(223) 评论(0) 推荐(0)

2017年3月13日

多项式相加(顺序表)

摘要: #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 阅读(1611) 评论(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)

2017年3月9日

数学算式搜索问题

摘要: #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 阅读(134) 评论(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 阅读(80) 评论(0) 推荐(0)

2017年3月3日

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 阅读(219) 评论(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 阅读(286) 评论(0) 推荐(0)

2017年2月28日

dfs:x+y=z

摘要: x+y=z 阅读全文

posted @ 2017-02-28 10:43 ewitt 阅读(100) 评论(0) 推荐(0)

dfs:10元素取5个元素的组合数

摘要: 分析:深度搜索dfs(int min,int max ,int num,int lable[])这里的参数之所以加入min与max,因为每次搜索的元素范围都是变化的。 阅读全文

posted @ 2017-02-28 10:35 ewitt 阅读(268) 评论(0) 推荐(0)

导航