您的位置:首页 > 其它

(2)Fibonacci数列

2013-11-19 20:07 141 查看
// sf1.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "iostream"
using namespace std;

void hanno(int n,char A,char B, char C)
{
if(n==1)
{cout<<"move sheet "<<n<<"from "<<A<<"to "<<C<<endl;}
else
{
hanno(n-1,A,C,B);
cout<<"move sheet "<<n<<"from"<<A<<"to"<<C<<endl;
hanno(n-1,B,A,C);

}
}

int main()
{
int n;
cout<<"please input the sheet number:"<<endl;

cin>>n;
hanno(n,'A','B','C');
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: