U E D R , A S I H C RSS

하노이탑/김태훈

~cpp #include <stdio.h>

int hanoi(int, int, int, int);
void move(int, int);

int main()
{

	hanoi(2,1,3,2);


}

int hanoi(int n, int a, int b, int c)
{
	if(n>0)
	{
		hanoi(n-1,a,c,b);
		move(a,b);
		hanoi(n-1,c,b,a);
	}

}


void move(int from, int to)
{
	printf("%d->%d ",from,to);
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:29
Processing time 0.0074 sec