#include <stdio.h>
#include <stdlib.h>
void towerOfHanoi(int n, char from, char to, char temp);
int main()
{
towerOfHanoi(5,'A','C','B');
return 0;
}
void towerOfHanoi(int n, char from, char to, char temp){
if(n > 0){
towerOfHanoi(n-1, from, temp, to);
printf("move from disk %d from %c to %c\n", n,from, to);
towerOfHanoi(n-1, temp, to, from);
}
}
Tower of Hanoi
最新推荐文章于 2022-10-31 23:21:00 发布