// 写法1: publicstaticvoidmain(String[] args){ // n为在对人数,out为当前出列的人 int n=0,out=0; Scanner sc = new Scanner(System.in); int aa = sc.nextInt(); int[] a = newint[aa];
// 写法2(ZB): publicclassYuesefu{ publicstaticvoidmain(String[] args){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int [] arr = newint[n]; int count = 0; int sum = 0;
for (int i = 0; sum < arr.length -1; i++) { if (i==arr.length) { i = 0; } if (arr[i] == 0) { count ++; } if (count == 3) { arr[i] = 1; count = 0; sum++; } }
for (int i = 0; i < arr.length; i++) { if (arr[i] == 0) { System.out.println(i+1); } } } }