经典笔试题-编程题:设有n个人依围成一圈,从第1个人开始报数,数到第m个人出列,然后从出列的下一个人开始报数,数到第m个人又出列,…,如此反复到所有的人全部出列

    private static boolean same(int[] p,int l,int n){
        for(int i=0;i playerNum*step){
                break;
            }
            for(int i=1;i playerNum)break;
                if(counter%step==0){
                    System.out.print(i + " ");
                    p[counter/step-1]=i;
                }
                counter+=1;
            }
        }
        System.out.println();
    }
    public static void main(String[] args) {
        play(10, 7);
    }

你可能感兴趣的:(经典笔试题)