汉诺塔模板

#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;
}

 

posted @ 2019-03-28 22:56  菜の可怜  阅读(137)  评论(0编辑  收藏  举报