U E D R , A S I H C RSS

하노이탑/이재혁김상섭

~cpp 
#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);
	}
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0370 sec