他们相邻两数的和 无非是 3 ,5 ,7,11这四个结果你从结果来考虑 对结果合理的排序3 =(1,2) 5 = (2,3) or (1,4) 7=(1,6) or (2,5) or (3,4) 11=(5,6)其间的组合 就不用说了吧!

解决方案 »

  1.   

    3 4 1 2 5 6 <=> 6 5 2 1 4 33 4 1 6 5 2 <=> 2 5 6 1 4 3 4 1 6 5 2 3 <=> 3 2 5 6 1 41 6 5 2 3 4 <=> 4 3 2 5 6 1 6 5 2 3 4 1 <=> 1 4 3 2 5 65 2 3 4 1 6 <=> 6 1 4 3 2 52 3 4 1 6 5 <=> 5 6 1 4 3 2 . . . .. ..........
      

  2.   

    import java.util.*;class arrPLJO 
    {
    static void print(String left,String right)
    {
    int n=right.length();
    if(n==0)return;
    else if(n==1)
    {
    StringBuffer arr=new StringBuffer(left+right);
    boolean F=true;
    //System.out.println(arr);
    int m=(int)arr.charAt(0)+(int)arr.charAt(5)-96;
    //System.out.println(m);
    //System.out.println((m!=2&&m!=3&&m!=5&&m!=7&&m!=11));
    if (m!=2&&m!=3&&m!=5&&m!=7&&m!=11)F=false;
    for(int i=1;(i<6)&&F;i++)
    {
    m=(int)arr.charAt(i-1)+(int)arr.charAt(i)-96;
    //System.out.println(m);
    if (m!=2&&m!=3&&m!=5&&m!=7&&m!=11)F=false;

    if (F)System.out.println(arr);
    }
    else
    {
    StringBuffer s=new StringBuffer(right);
    for(int i=0;i<n;i++)
    {
    char tmp=s.charAt(i);
    s.setCharAt(i,s.charAt(0));
    s.setCharAt(0,tmp);
    print(left+tmp,s.substring(1,n));
    }
    }
    }
    public static void main(String[] args) 
    {
    print("","123456");
    //System.out.println("Hello World!");
    }
    }
    ---------- Run Java Program ----------
    143256
    165234
    234165
    256143
    325614
    341652
    416523
    432561
    523416
    561432
    614325
    652341Output completed (0 sec consumed) - Normal Termination