package tools;
import java.util.LinkedList;
public class Demo {
public static void main(String[] args) {
LinkedList<Integer> link = new LinkedList<Integer>();
for (int i = 0; i < 10000; i++) {// 假如有10000个学生
link.add(new Integer(i));
}
int count = 0;
int current = 0;
while (link.size() != 1) {
if (current >= link.size()) {
current = 0;
}
if ((count + "").indexOf("3") != -1) {
link.remove(current);
}
count++;
current++;
}
System.out.println("最后一个学生的编号是:" + link.get(0));
}
}
新手不容易,给个技术分吧
|
|