调用函数求解汉诺塔问题

#include<stdio.h>
void move(char getone,char putone)
{printf("%c-->%c\n",getone,putone);
}void m(int n,char one,char two,char three)
{if(n==1)
move(one,three);
else{m(n-1,one,three,two);
{
move(one,three);
m(n-1,two,one,three);}
}
    
}
int main(){
int n;
printf("disks:");
scanf("%d",&n);
printf("%3d\n",n);
m(n,'A','B','C');
return 0;    
    
    
    
}

猜你喜欢

转载自blog.csdn.net/qq_41479464/article/details/82735195