文件名称: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
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.