标题:求汉诺塔算法实现过程中参数是如何变化的及详解。
取消只看楼主
花脸
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:9
帖 子:788
专家分:907
注 册:2017-1-4
结帖率:95.37%
已结贴  问题点数:20 回复次数:1 
求汉诺塔算法实现过程中参数是如何变化的及详解。
#include<stdio.h>

void move(char x,char y)
{
   printf("%c-->%c\n",x,y);
}
//将n个盘从one座借助two座,移到three座
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);//
    }
}

int main()
{
  int n;
  printf("input the number of diskes:\n");
  scanf("%d",&n);
  printf("The step to moving %3d diskes:\n",n);
  hanoi(n,'A','B','C');
  return 0;
}
搜索更多相关主题的帖子: 汉诺塔 char printf one hanoi 
2017-10-13 21:01
花脸
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:9
帖 子:788
专家分:907
注 册:2017-1-4
得分:0 
回复 2楼 炎天
2017-10-13 21:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-481365-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.651134 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved