猴子报数选大王
摘要:题目:n只猴子要选大王,选举办法如下:所有猴子按1,2,…,n编号围坐一圈,从第1号开始按1,2,…m报数,凡报到m号的退出到圈外,如此循环报数,直到圈内剩下最后一只猴子时,这只猴子就是大王,n和m由键盘输入,打印出最后剩下的猴子号。分析:用一个含有n个元素的一维数组a来存储猴子的编号,初始时a[i]存放的是猴子的编号i。开始时,从a[0]开始报数,用count来表示报...
阅读全文
posted @
2010-10-28 21:15
几度夕阳红了
阅读(807)
推荐(0) 编辑
KMP算法
摘要:KMP算法的关键在于模式字符串的处理,就是如何求next数组的值我以为关键点就在于就是要找到k的值ababacde如果到最后一个a的话,最前面的ab和最后一个a前面的ab相等,所以k为2abacacde如果到最后一个a的话,a前面的c,在abac里中,没有字符满足,所以就是0
阅读全文
posted @
2010-10-27 12:20
几度夕阳红了
阅读(206)
推荐(0) 编辑
char *p="abc"与char p[]="abc"的不同
摘要:问题引入:在实习过程中发现了一个以前一直默认的错误,同样char *c = "abc"和char c[]="abc",前者改变其内容程序是会崩溃的,而后者完全正确。程序演示:测试环境Devc++代码#include <iostream>using namespace std;main(){ char *c1 = "abc"; char c2[] = "abc"; char *c3 = ...
阅读全文
posted @
2010-10-26 17:58
几度夕阳红了
阅读(354)
推荐(0) 编辑
编写打印出一个单链表的所有元素的程序
摘要://Building a linked list in C//The following program shows how a simple, linear linked list can be constructed in C, using dynamic memory allocation and pointers. #include "stdafx.h"#include<stdlib...
阅读全文
posted @
2010-10-23 16:17
几度夕阳红了
阅读(4772)
推荐(0) 编辑
I will greet this day with love in my heart.
摘要:有一句话这样说:昨天已经过去,明天还没有来到,今天就在眼前。昨天已成黄花,明天还是一场梦,只有今天是实实在在的。这话的道理不言而喻,想一想,与其回忆,不如把握住今天;与其渴望明天,不如让今天给明天创造一片蔚蓝的天空。I will greet this day with love in my heart.For this is the greatest secret of success in al...
阅读全文
posted @
2010-10-20 10:23
几度夕阳红了
阅读(685)
推荐(0) 编辑
C#登录拍拍,总是提示输入有误
摘要:因为市场需求,这几天在整,用程序实现拍拍登录。据我的经验所知,QQ登录有时候需要验证码,有时候就不需要,这个产生的原因大概是,你如果QQ经常的登录的话,说明QQ是正常的,在登录的时候,输入完用户名后,就不会提示你输入验证码。如下图:这样,你只要输入正确密码就可以成功登录了。而如果是经常不用的话,比如1228897656,先声明下,这两个QQ号都是我的。在QQ账号旁边的文本框失去焦点后,就会显示验证...
阅读全文
posted @
2010-10-13 10:23
几度夕阳红了
阅读(4885)
推荐(0) 编辑
Knapsack problem(背包问题)
摘要:The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection ...
阅读全文
posted @
2010-10-06 11:55
几度夕阳红了
阅读(1127)
推荐(0) 编辑
汉诺塔问题
摘要:汉诺塔Demo PageThe Tower of Hanoi or Towers of Hanoi is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts ...
阅读全文
posted @
2010-10-01 21:55
几度夕阳红了
阅读(401)
推荐(0) 编辑
8皇后和N皇后问题
摘要:The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard such that none of them are able to capture any other using the standard chess queen's moves. The queens ...
阅读全文
posted @
2010-10-01 20:39
几度夕阳红了
阅读(364)
推荐(0) 编辑