하 탑..^^
~cpp
#include <iostream>
int answer=0;
void hanoi(int, int, int, int);
using namespace std;
void main()
{
int number;
cout << "하 탑 해 >>";
cin >> number;
hanoi (1,3,2,number);
cout << " "<< answer << ".";
}
void hanoi(int from, int middle, int target, int num)
{
++answer;
if (1==num)
{
cout << from << "" << target << " .\n";
}
else
{
hanoi (from, target, middle, num-1 );
cout << from << "" << target << " .\n";
hanoi (middle, from, target, num-1 );
}
}










