第1个回答 2009-06-22
public class Hang{
public void h(int n,char A,char B,char C){
if(n==1){
System.out.println(1+":"+A+"->"+B+"->"+C);
}
else{
h(n-1,A,C,B);
System.out.println(n+":"+A+"->"+B+"->"+C);
h(n-1,C,B,A);
}
}
public static void main(String args[])throws Exception{
new Hang().h(3,'A','B','C');
}
}
这难道不是递归啊 昏