文件名称:约瑟夫演示
介绍说明--下载内容均来自于网络,请自行研究使用
编号为1,2,…,n的n个人按顺时针方向围坐一圈,每人持有一个密码(正整数),一开始人选一个正整数作为报数上限m,从第一个人开始按顺时针方向从自1开始顺序报数,报道m时停止报数。报m的人出列,将他的密码作为新的m值,从他的顺时针方向上的下一个人开始重新从1报数,如此下去,直至所有人全部出列为止,设计一个程序求出出列顺序。采用单向循环链表模拟此过程,按照出列的顺序印出各人的编号测试数据:m的初值为20;n=7,7个人的密码依次为:3,1,7,2,4,8,4,首先m的值为6(正确的出列顺序应为6,1,4,7,2,3,5)-No. 1, 2, ..., n n clockwise direction by individuals sitting around a circle, each holding a password (positive integers), a candidate started as a positive integers m ceiling on the number of reported from the first individuals to embark on the clockwise direction from the start sequence from a few newspaper reports m reportedly stopped a few. M reported out of the list of his password as a new value m, from the clockwise direction on the next re-started from a few reported so on, until all out all out, the design of a procedure sought out the order out. Listless one-cycle simulation process and follow the sequence shown in the numbers printed each test data : m for the initial 20; N = 7,7 personal passwords were : 3,1,7,2,4,8,4, first the value of m 6 (right to be out of order out 6,1,4
相关搜索: 约瑟夫
(系统自动生成,下载前可以参看下载内容)
下载文件列表
约瑟夫环
........\约瑟夫环.cpp
........\约瑟夫环.cpp