汉诺塔

汉诺塔

//汉诺塔
#define LOCAL
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<iomanip>
#include<string>
#include<algorithm>
#include<ctime>
#include<stack>
#include<queue>
#include<vector>
using namespace std;

int num = 1;

void move(char a, char b)
{
	cout << "Step " << num++ << " : " << a << "-->" << b << endl;
}

void hanoi(int level, char a, char b, char c)
{
	if (level < 1)
		return;
	hanoi(level - 1, a, c, b);
	move(a, c);
	hanoi(level - 1, b, a, c);
}

int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	hanoi(3, 'A', 'B', 'C');
	return 0;
}

发表回复