#include <stdio.h>
int count1=0;
int count2=0;
void main()
{
int hanoi(int n,char one,char two,char three);
int Hanoi(int n,char one,char two,char three);
int m,b,c;
printf("input the number of diskes:");
scanf("%d",&m);
printf("The step to moving %d diskes:\n",m);
b=hanoi(m,'A','B','C');
printf("%d\n",b);
c=Hanoi(m,'A','B','C');
printf("%d\n",c);
}
int hanoi(int n,char one,char two,char three)
{
void move(int i,char x,char y);
if(n==1)
{
move(n,one,three);
count1++;
}
else
{
hanoi(n-1,one,three,two);
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载