我的代码是- import java.util.ArrayList;
 
  
- /*
 
 -  * 有100个人围成一个圈,
 
 -  * 从1开始报数,报到14的这个人就要退出。
 
 -  * 然后其他人重新开始,
 
 -  * 从1报数,到14退出。
 
 -  * 问:最后剩下的是100人中的第几个人?
 
 -  */
 
 - public class Test {
 
 -         public static void main(String[] args)
 
 -         {
 
 -                   ArrayList<Integer> al = new ArrayList<Integer>();
 
 -           for(int x = 1; x<=100; x++)
 
 -                   al.add(x);
 
 -          int c = 1;
 
 -          Method(al,c);
 
 -          for(int x = 0;x<al.size();x++)
 
 -          {
 
 -                  System.out.println(al.get(x));
 
 -          }
 
 -          //System.out.print(al.size()+"  ");//打印最后剩下数的长度
 
 -          
 
 -         }
 
 -         private static void Method(ArrayList<Integer> al,int c)
 
 -         {
 
 -                 ArrayList<Integer> al2 = new ArrayList<Integer>();
 
 -                 for(int x = 0;x<al.size();x++,c++){
 
 -                         if((c % 14)==0){
 
 -                                 al2.add(al.get(x));
 
 -                                 //System.out.print(al.get(x)+"  ");//打印每次需要排除的元素
 
 -                         }
 
 -                 }
 
 -                 al.removeAll(al2);
 
 -                 if(al.size()>13)
 
 -                         Method(al, c);
 
 -         }
 
 - }
 
  复制代码 |