第08节 函数.pptVIP

  • 1
  • 0
  • 约1.01万字
  • 约 69页
  • 2017-06-03 发布于湖北
  • 举报
程序如下: #include stdio.h void 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)

1亿VIP精品文档

相关文档