2013年6月30日

建树

摘要: 输入从根节点开始的路径,输出层次遍历的结果样例输入(3,L)(2,R)()输出:1 3 2指针实现 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn=100; 7 char s[maxn]; 8 int fail=0; 9 typedef struct tnode 10 { 11 int have_val; 12 int u; 13 tnode *right,*left; 14 }node; 15 node *root; 16 int ... 阅读全文

posted @ 2013-06-30 15:17 the unkown road 阅读(359) 评论(0) 推荐(0)

不重复组合

摘要: 组合 阅读全文

posted @ 2013-06-30 15:02 the unkown road 阅读(264) 评论(0) 推荐(0)

全组合

摘要: 输入n个数,求这n个数构成的集合的所有自己31 2 3输出11 21 2 31 322 33代码: 1 #include 2 #include 3 using namespace std; 4 const int maxn = 100; 5 6 int n,m; 7 int rcd[maxn],num[maxn],vis[maxn]; 8 9 int read_input(){10 11 if(scanf("%d",&n)==EOF)12 return 0;13 for(int i=0;i 2 #include 3 using namespace std; 4... 阅读全文

posted @ 2013-06-30 14:50 the unkown road 阅读(161) 评论(0) 推荐(0)

一般组合

摘要: 输入n个数,从中选出m个数可欧构成集合,输出所有这样的集合输入4 31 2 3 4输出1 2 31 2 41 3 42 3 4代码: 1 #include 2 #include 3 using namespace std; 4 const int maxn = 100; 5 6 int n,m; 7 int rcd[maxn],num[maxn],vis[maxn]; 8 9 int read_input(){10 11 if(scanf("%d %d",&n,&m)==EOF)12 return 0;13 for(int i=0;i<n;i++)14 阅读全文

posted @ 2013-06-30 14:40 the unkown road 阅读(160) 评论(0) 推荐(0)

不重复排列

摘要: 输入n个数值,输出由这n个数构成的排列,不允许出现重复的项输入31 1 2输出1 1 21 2 12 1 1代码 1 #include 2 #include 3 using namespace std; 4 const int maxn = 100; 5 int rcd[maxn],num[maxn],vis[maxn]; 6 int n,m; 7 int read_input() 8 { 9 if(scanf("%d",&n)==EOF)10 return 0;11 m=0;12 memset(vis,0,sizeof(vis));13 int... 阅读全文

posted @ 2013-06-30 14:35 the unkown road 阅读(255) 评论(0) 推荐(0)

全排列

摘要: 对输入的n个数做全排列样例输入31 2 3输出1 2 31 3 22 1 32 3 13 1 23 2 1 1 /* 2 1...n全排列,不计算是否有重复 3 */ 4 #include 5 #include 6 using namespace std; 7 const int maxn = 100; 8 9 int rcd[maxn],num[maxn],vis[maxn];10 int n;11 12 int input(){13 if(scanf("%d",&n)==EOF)14 return 0;15 memset(vis,0,sizeof(vis)... 阅读全文

posted @ 2013-06-30 14:32 the unkown road 阅读(125) 评论(0) 推荐(0)

导航