首页 > 其他 > 详细

汉诺塔模板

时间:2019-03-28 23:16:08      阅读:141      评论:0      收藏:0      [点我收藏+]
#include<iostream>
#include<cstdio>
using  namespace std;
void hanor(int src,int mid,int desk,int count){
    if(count==1){
        printf("%c -> %c\n",src,desk);
        return;
    }
    hanor(src,desk,mid,count-1);
    printf("%c %c\n",src,mid);
    hanor(mid,src,desk,count-1);
}
int main()
{
    int n;
    scanf("%d",&n);
    hanor(a,b,c,n);
    return 0;
}

 

汉诺塔模板

原文:https://www.cnblogs.com/wysAC666/p/10618409.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!