hannuo tower

来源:互联网 发布:3dmax mac中文破解版 编辑:程序博客网 时间:2024/05/16 19:48

hanuota.cpp


#include<iostream>using namespace std;void hanuota(int n,char source,char destination,char depend){    if(n==1)        cout<<n<<"   "<<source<<"-------->>"<<destination<<endl;    else{        hanuota(n-1,source,depend,destination);        cout<<n<<"   "<<source<<"-------->>"<<destination<<endl;        hanuota(n-1,depend,destination,source);    }} 

经典的递归思想。

0 0