借助队列解决Josephus问题

`Queue queue = new Queue ();
for  (int i = 0; i < total; i++)

    queue.enqueue(i);

while (!queue.isEmpty()) {

    for (int i = 0; i < M-1; i++)
            queue.enqueue(q.dequeue());
    System.out.println(q.dequeue() + "");

}
`

你可能感兴趣的:(借助队列解决Josephus问题)