import java.util.ArrayList;
import java.util.List;
public class TestCircle {
public static void to(int total, int number) {
List<Integer> list = new ArrayList<Integer>(total);
for (int i = 1; i <= total; i++) {
list.add(i);
}
int begin = -1;
while (total > 0) {
begin += number;
System.out.println(list.remove(begin % total));
begin = (begin % total) - 1;
total--;
}
}
/**
* @param args
*/
public static void main(String[] args) {
TestCircle.to(10, 3);
}
}
5n个人围成圈,报数为m的出局顺序问题
最新推荐文章于 2023-02-14 17:04:34 发布