1 //简单到不能再简单的递归实现 2 #include<stdio.h> 3 4 void hano(int n,char A,char B,char C) 5 { 6 //终止条件 7 if(n==1) 8 { 9 printf("Move disk %d from %c to %c \n",n,A,C); 10 } 11 else 12 { 13 hano(n-1,A,C,B); 14 printf("Move disk %d from %c to%c \n",n,A,C); 15 hano(n-1,B,A,C); 16 } 17 } 18 19