Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

하노이탑/이재혁김상섭

From ZeroWiki
#include <iostream>

using namespace std;

int num(int val, int start, int end);

int main()
{
	cout << num(3, 1, 2) << endl;

	return 0;
}

int num(int val, int start, int end)
{
	
	if(val == 1)
	{
		cout << start << "->" << end << endl;

		return 1;
	}
	else
	{
		return num(val - 1, start, 6-start-end) + num(1,start,end) + num(val - 1, 6-start-end, end);
	}
}

김상섭 하노이탑