洪晓涛homework5 Version 0 |
|
👤 Author: by 1063619228qqcom 2016-11-29 22:08:52 |
#include
void move(char get, char put)
{printf("%c-->%c\n",get,put);}
void hanoi(int n,char one,char two,char three)
{if(n==1)move(one,three);
else {hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);}}
int main(){
int m;
printf("Input the number of disks:");
scanf("%d",&m);
printf("The steps:\n");
hanoi(m,'A','B','C');
return 0;
}
because pow(2,30)is big,maybe we need more space to store