A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

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));
        }
}


新手不容易,给个技术分吧

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马