求下面算法中的move 函数的写法

来源:百度知道 编辑:UC知道 时间:2024/06/08 07:50:53
该算法是
void hanoi(int n,char x,char y,char z)
printf("%i.Move disk %i from %c to %c\n",++c,n,x,z);
{
if(n==1)
move(x,1,z);
else {
hanoi(n-1,x,z,y);
move(x,n,z);
hanoi(n-1,y,x,z);
}
}

main()
{ int n;
void hanoi(int n,char b,char c);
printf("Please enter the number of disks to be moved:");
scanf("%d",&n);
hanoi(n,'a','b','c');
}
void hanoi(int n,char a,char b,char c)
{ if(n>0)
{ hanoi(n-1,a,c,b);
printf("\n Move disc %d from pile %c to pile %c",n,a,b);
hanoi(n-1,c,b,a);
}
}

给你个完整程序