文件名称:chagnshengjiangjun
介绍说明--下载内容来自于网络,使用问题请自行百度
常胜将军
现有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
现有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
www.dssz.com.txt
www.dssz.com.txt
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.