参考链接
https://www.cnblogs.com/xt0810/p/3442840.html
#include <stdio.h> #include <stdlib.h> int Hanoi(int n,char A, char B, char C) { if (n == 1) { printf("Move sheet %d from %c to %c ",n,A,C); } else { Hanoi(n-1,A,C,B); printf("Move sheet %d from %c to %c ",n,A,C); Hanoi(n-1,B,A,C); } return 0; } int main() { int n; printf("请输入盘子个数:"); scanf("%d",&n); Hanoi(n,'A','B','C'); printf("Hello world! "); return 0; }