ab的排列 aa , ab ba,bb

package reverseList;





public class Main {

    static void perm(char c[],int lev,char ans[])

    {

        if(c.length==lev)

        {

            System.out.println(String.valueOf(ans));

        }

        else

        {

        for(int i=0;i<c.length;i++)

        {

            ans[lev]=c[i];

            perm(c,lev+1,ans);

            

            

            

        }

        }

        



    }



    public static void main(String[] args) {

        // TODO Auto-generated method stub

        char c[]="ab".toCharArray();

        char ans[]=new char[3];

        perm(c,0,ans);

        

        



    }



}

你可能感兴趣的:(ab)