- 2
- 0
- 约1.01万字
- 约 69页
- 2017-02-28 发布于湖北
- 举报
程序如下:#include stdio.hvoid move (char getone,char putone) /*函数定义*/{ printf(“ %c– –%c\n ”, getone, putone);}void hanoi (int n, char one, char two, char three) /*将n个盘从one借助two,移到three*/ { if (n= =1) move (one, three); else { hanoi (n–1, one, three, two); move (one, three); /*函数调用*/ hanoi (n–1, two, one, three); }} main ( ){ int m; printf (“ input the number of diskes ” :); scanf(“ %d ”,m); printf(“ The step to moving %3d diskes:\n ”, m); hanoi (m, ‘A’, ‘B’, ‘C’);
原创力文档

文档评论(0)