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 阅读(347) 评论(0) 推荐(0) 编辑

不重复组合

摘要: 组合 阅读全文

posted @ 2013-06-30 15:02 the unkown road 阅读(254) 评论(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 阅读(149) 评论(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 阅读(152) 评论(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 阅读(241) 评论(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 阅读(117) 评论(0) 推荐(0) 编辑

2013年3月29日

Scout YYF I_poj3744

摘要: DescriptionYYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. After overcoming a series difficulties, YYF is now at the start of enemy's famous "mine road". This is a very long road, on which there are numbers of mines. At first, 阅读全文

posted @ 2013-03-29 21:09 the unkown road 阅读(90) 评论(0) 推荐(0) 编辑

2013年3月28日

Collecting Bugs_poj2096

摘要: DescriptionIvan is fond of collecting. Unlike other people who collect post stamps, coins or other material stuff, he collects software bugs. When Ivan gets a new program, he classifies all possible bugs into n categories. Each day he discovers exactly one bug in the program and adds information abo 阅读全文

posted @ 2013-03-28 10:58 the unkown road 阅读(92) 评论(0) 推荐(0) 编辑

One Person Game

摘要: Time Limit:1 Second Memory Limit:32768 KB Special JudgeThere is a very simple and interesting one-person game. You have 3 dice, namelyDie1,Die2andDie3.Die1hasK1faces.Die2hasK2faces.Die3hasK3faces. All the dice are fair dice, so the probability of rolling each value, 1 toK1,K2,K3is exactly 1 /K1, 1 / 阅读全文

posted @ 2013-03-28 10:39 the unkown road 阅读(164) 评论(0) 推荐(0) 编辑

2013年3月27日

只有程序员才看得懂的情书

摘要: 我能把整个世界都抽象成对象... 但是没办法把你变成我的对象... 想让你成为私有常量,外部函数无法访问你… 又想让你变成全局常量,在整个生命周期随时随地都可以调用你… 因为世界上没有这样的常量...所以我的无法定义你... 我可以重载甚至覆盖任何一种方法... 但是我却不能重载对你的思念... 也许命中注定了 你在我的世界里永远的烙上了静态的属性... 而我不慎调用了爱你这个方法... 当我义无返顾的把自己作为参数传进这个方法时... 我才发现方法"爱你"里面执行是一个死循环... 她不停的返回对你的思念存入我心里的堆栈... 在这无尽的无穷无尽循环中... 我的内存资源 阅读全文

posted @ 2013-03-27 20:29 the unkown road 阅读(108) 评论(0) 推荐(0) 编辑

导航