Home > Back-end >  Circular linked list Joseph problem!!
Circular linked list Joseph problem!!

Time:10-18

[problem description]
Joseph (Joseph) a description of the problem is: Numbers for 1, 2,... , n n individuals according to
Clockwise around a circle, each holding a password (positive integer), first choose a
Positive integer as the upper limit count off m, since the first man since 1 clockwise order
Count off, stop count off when reporting for m, m people break the ranks, his password as the new m values,
In clockwise direction from him the next person to start to count off from 1, so go on, until the
Someone out all, try to design a program to find the dequeue order,
[basic requirements]
Using one-way circular linked list storage structure to simulate this process, in accordance with the order of the dequeue printed each
The number of,
[test data]
Any given by the students,
Such as: the initial value of 20 m; N value of 7; Password: 3,1,7,2,4,8,4;
(the correct output should have 6,1,4,7,2,3,5),
(the report asked to write multiple data on the test result)
Why always wrong after the last person out! ?????????? Please explain

  • Related