Hanoi问题在C语言程序设计中的应用

void move(char getone, char putone) { printf("%c-->%c
", getone, putone); } 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); } } void main() { int m; printf("输入盘子数量:"); scanf("%d", &m); printf("移动 = 个盘子的步骤:
", m); hanoi(m, 'A', 'B', 'C'); }
ppt 文件大小:9.28MB