文件名称:joseph
介绍说明--下载内容均来自于网络,请自行研究使用
约瑟夫环(Joseph)问题的一种描述是:编号为1,2,…,n的n个人按顺时针方向围坐一圈,每人持有一个密码(正整数)。一开始任选一个正整数作为报数上限值m,从第一个人开始按顺时针方向自1开始顺序报数,报到m时停止报数。报m的人出列,将他的密码作为新的m值,从它在顺时针方向的下一个人开始重新从1报数,如此下去,直至所有人全部出列为止。试通过累的设计求解约瑟夫环问题的出列顺序。具体要求和说明如下:
(1) 利用单向循环列表存储结构模拟此过程,按照出列的顺序输出个人的编号。
(2) m的初值为20;n=7,7个人的密码依次为:3,1,7,2,4,8,4,首先m的值为6(正确的出列顺序应为:6,1,4,7,2,3,5)。
(3) 程序运行后,首先要求用户指定初始报数的上限值,然后读取个人的密码。可设n<=30,此题所用的循环列表中不需要“头结点”,请注意空表和非空表的界限。
(4) 将上述功能改为在顺序结构上实现。-A descr iption of Josephus (Joseph) the problem is: numbered 1,2, ..., n by n individuals sitting clockwise circle, each holding a password (positive integer). Optional start a positive integer as the number of reported upper limit m, the first person to start a clockwise direction since the beginning of the sequence reported number, the number of reported stops at registration m. M people out newspaper columns, his password as the new value of m, its beginning in the next person in a clockwise direction a number off again, and so on, until all the columns until everyone. Trial design by tired Josephus problem solving out the order of columns.
(1) 利用单向循环列表存储结构模拟此过程,按照出列的顺序输出个人的编号。
(2) m的初值为20;n=7,7个人的密码依次为:3,1,7,2,4,8,4,首先m的值为6(正确的出列顺序应为:6,1,4,7,2,3,5)。
(3) 程序运行后,首先要求用户指定初始报数的上限值,然后读取个人的密码。可设n<=30,此题所用的循环列表中不需要“头结点”,请注意空表和非空表的界限。
(4) 将上述功能改为在顺序结构上实现。-A descr iption of Josephus (Joseph) the problem is: numbered 1,2, ..., n by n individuals sitting clockwise circle, each holding a password (positive integer). Optional start a positive integer as the number of reported upper limit m, the first person to start a clockwise direction since the beginning of the sequence reported number, the number of reported stops at registration m. M people out newspaper columns, his password as the new value of m, its beginning in the next person in a clockwise direction a number off again, and so on, until all the columns until everyone. Trial design by tired Josephus problem solving out the order of columns.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
程序.docx