1200=汉诺塔

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 void recursive(int n,char A,char B,char C)
 4 {
 5     if(n==1)printf("Move disk %d from %c to %c
",n,A,C);//每一个的第一步要把A上的一个移动到B上。
 6     else
 7     {
 8         recursive(n-1,A,C,B);//B和C的位置要互换,因为下一步是要把A移动到C上。
 9         printf("Move disk %d from %c to %c
",n,A,C);
10         recursive(n-1,B,A,C);//再次交换,把B移动到C上。
11     }
12 }
13 int main()
14 {
15     int n;
16     scanf("%d",&n);
17     recursive(n,'A','B','C');
18     return 0;
19 }
原文地址:https://www.cnblogs.com/Angfe/p/10497691.html