n个孩子围成一圈问题就看这一篇 import java.util.Scanner; public class Child { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("请输入一个整数:"); Scanner scan=new Scanner(System.in); int n = scan.nextInt(); scan.close(); boolean[]isIn = new boolean[n]; for(int i = 0;i<isIn.length;i++)//定义数组变量标识某人是否还在圈内 isIn[i] = true; //定义圈内人数、报数、索引 int inCount = n; int countNum = 0; int index = 0; while(inCount>1) { if (isIn[index]) countNum++; index++; if(countNum==3) { isIn[index]=false; countNum=0; inCount--; } if(index==n-1) index=0; } index++; System.out.println("算机1902 徐伟炫"); System.out.println("最后留下的是原来第"+index+"号的小孩"); } }