汉诺塔(hanoi)算法实现

#include
#include
#include
#include
#include 
#include 
using namespace::std;



class Solution {
public:
	Solution():n(2)
	{
	stack tower1;
	stack tower2;
	stack tower3;
	hanoi.push_back(tower1);
	hanoi.push_back(tower2);
	hanoi.push_back(tower3);
	for(int i = n; i > 0 ; i--)
	{
		hanoi[0].push(i);
	}
	}

	void print(stack tower)
{

	while(tower.size() != 0)
	{		
		cout<& start, stack& end, stack& buffer, int layer)
	{

		int tmp = 0;
		if(layer > 0)
		{

//		cout<<"layer: "<> hanoi;
	int n;

};

终于圆了大一C语言课的梦,征服了汉诺塔


你可能感兴趣的:(Algorithm)