文件名称:猴子选大王
介绍说明--下载内容均来自于网络,请自行研究使用
猴子选大王,有N只猴子,从1~N进行编号。它们按照编号的顺时针方向,排成一个圆圈,然后从第一只猴子开始报数。第一只猴子报1,以后每只猴子报的数字都是它前面猴子所报数字加1。如果一只猴子报的数字是M,则该猴子出列,下一只猴子重新从1开始报数。剩下的猴子继续排成一个圆圈报数,直到全部的猴子都出列为止。最后一个出列的猴子胜出。按照上述规则,编写程序选出排成一圈的猴子中的大王。(Monkey King, N monkeys, numbered from 1 to N. They are in accordance with the number of clockwise, arranged in a circle, and then start off from the first monkey. The first monkey reported 1, and then each monkey reported the number of monkeys in front of it, plus 1. If a monkey's numbers is M, the monkey out of a monkey from 1 to start off again. The rest of the monkey to row into a circle off, until all the monkeys are out of date. The last one out of the monkey. According to the above rules, the program is written to select the king of monkeys in a circle.)
相关搜索: 猴子选大王
(系统自动生成,下载前可以参看下载内容)
下载文件列表
文件名 | 大小 | 更新时间 |
---|---|---|
猴子选大王.cpp | 2319 | 2017-03-27 |