package utils;
import java.util.ArrayList;
import java.util.List;
public class PeopleCount {
public static String peopleCount(List people) {
int max = 0;
while (true) {
if (people.size() == 1) {
return people.get(0).toString();
}
for (int j = 0; j < people.size(); j++) {
max++;
if (max % 3 == 0) {
System.out.println(people.get(j) + "被删除");
people.remove(j);
j--;
}
}
}
}
public static void main(String[] args) {
List people = new ArrayList();
for (int i = 0; i < 17; i++) {
people.add(i);
}
System.out.println("最后出局的是:" + peopleCount(people));
}
}