约瑟夫出圈问题
import java.util.Scanner;public class joseph {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubScanner s = new Scanner(System.in);System.out.println("输入总人数:");int total = s.nextInt();System.out.println("输入报名数:");int num = s.nextInt();Node n1 = new Node(1);Node pointer = n1;for (int i = 2; i <= total; i++) {pointer.next = new Node(i);pointer = pointer.next;}pointer.next = n1;while (pointer != pointer.next) {for (int i = 1; i < num; i++) {pointer = pointer.next;}System.out.println(pointer.next.number);pointer.next = pointer.next.next;}System.out.println(pointer.number);}}