class Hanoi
  { private int c;
      public Hanoi()
        { c=0; }
      public void move(char getone,char putone)
        { c=c+1;
          System.out.println(getone+"-->"+putone+"搬盘次数为："+c);
        }
    public void hanoi(int n,char one,char two,char three)
        { if(n==1) move(one,three);
          else
          { hanoi(n-1,one,three,two);
            move(one,three);
            hanoi(n-1,two,one,three);
          }
        }
  }

public class HanoiTest
  {public static void main(String args[])
    { int m=4;
      System.out.println("搬"+m+"个盘数的步骤;");
      Hanoi a=new Hanoi();
      a.hanoi(m,'A','B','C');
    }
  }
