文件名称:Joseph-algorithm
介绍说明--下载内容均来自于网络,请自行研究使用
约瑟夫算法:n个人围成一圈,每人有一个各不相同的编号,选择一个人作为起点,然后顺时针从1到k数数,每数到k的人退出圈子,圈子缩小,然后从下一个人继续从1到k数数,重复上面过程。求最后推出圈子的那个人原来的编号。
思路:按照上面的算法让人退出圈子,直到有n-1个人推出圈子,然后得到最后一个退出圈子的人的编号。
程序:坐成一圈的人的编号不需要按序排列-Joseph algorithm: n individuals in a circle, each with a different number, choose a person as a starting point, and then clockwise to count from 1 to k, each count to exit the circle k, narrow circle, and then from the next person to continue to count from 1 to k, repeat the above process. And the man finally launched circle of the original number.
Idea: according to the above algorithm to exit the circle, until there is n- 1 personal circle, and then get the final out of the number people.
The serial number of procedures: sit in a circle of people do not need to be arranged in sequence
思路:按照上面的算法让人退出圈子,直到有n-1个人推出圈子,然后得到最后一个退出圈子的人的编号。
程序:坐成一圈的人的编号不需要按序排列-Joseph algorithm: n individuals in a circle, each with a different number, choose a person as a starting point, and then clockwise to count from 1 to k, each count to exit the circle k, narrow circle, and then from the next person to continue to count from 1 to k, repeat the above process. And the man finally launched circle of the original number.
Idea: according to the above algorithm to exit the circle, until there is n- 1 personal circle, and then get the final out of the number people.
The serial number of procedures: sit in a circle of people do not need to be arranged in sequence
(系统自动生成,下载前可以参看下载内容)
下载文件列表
约瑟夫环问题求解算法.C