[编程笔记] 汉诺塔问题 C语言

#include 

void main ()
{
	int n;
	char one, two, three;
	void hanoi(int , char , char , char);

	scanf ("%d,%c,%c,%c", &n, &one, &two, &three);
	hanoi (n, one, two, three);
}

void hanoi(int num, char a, char b, char c )
{
	void move (char,char);
	if (num == 1) {
		move (a,c);
	} else {
		hanoi (num-1,a,c,b);
		move (a,c);
		hanoi (num-1,b,a,c);
	}
}

void move (char a,char b)
{
	printf ("move it from %c to %c \n",a,b);
}

你可能感兴趣的:(coding)