하노이의 탑..^^
~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 );
	}
}


데블스캠프2005, 하노이탑
Retrieved from http://wiki.zeropage.org/wiki.php/하노이탑/조현태
last modified 2021-02-07 05:31:29