打印hanoi塔排序步骤
#include<stdio.h>
void hanoi(int ,char, char, char);
void move(char, char);
void main() {
int a=4;
printf("input your number of diskes\n");
hanoi(a, 'A', 'B', 'C');
}
void hanoi(int i,char one, char two, char three) {
if (i == 1)
move(one, three);
else
{
hanoi(i-1, one, three, two);
move(one, three);
hanoi(i-1, two, one, three);
}
}
void move(char x, char y) {
printf("%c----->%c\n", x, y);
}