chagnshengjiangjun

所属分类:数据结构
开发工具:Visual C++
文件大小:1KB
下载次数:8
上传日期:2006-10-22 00:20:53
上 传 者huangbo929
说明:  常胜将军 现有21根火柴,两人轮流取,每人每次可以取走1至4根,不可多取,也不能不取,谁取最后一楰火柴谁输。请编写一个程序进行人机对弈,要求人先取,计算机后取;计算机一方为“常胜将军”。 *问题分析与算法设计 在计算机后走的情况下,要想使计算机成为“常胜将军”,必须找出取 关键。根据本题的要求枷以总结出,后走一方取子的数量与对方刚才一步取子的数量之和等于,就可以保证最后一个子是留给先取子的那个人的。 据此分析进行算法设计就是很简单的工作,编程实现也十分容易。
(everlasting General existing 21 matches, two from rotation, each person could take from one to four, not to take on more. nor can we obtain, who take a final flourishing Who loses matches. Please procedures for the preparation of a human-machine game, the first to ask for and obtain computer; One computer to "everlasting generals."* Analysis and design of algorithms in the computer after taking the circumstances, in order to make the computer as "everlasting generals" must find out from the key. According to the requirements of this title to sum up their thoughts, after taking one for the number of children with each other- just one step and the amounts equal to, Finally we can guarantee a first son left for the children it is personal. Accordingly analysis algorithm )

文件列表:
常胜将军.C (1167, 2006-10-12)

近期下载者

相关文件


收藏者