- /*Hanoi.txt*/
- #include <stdio.h>
- void move(int h,char c,char f)
- {
- printf("%d:%c--->%cn",h,c,f);
- }
- void hanoi(int n,char x,char y,char z)
- {
- if(n==1)
- move(1,x,z);
- else{
- hanoi(n-1,x,z,y);
- move(n,x,z);
- hanoi(n-1,y,x,z);
- }
- }
- void main()
- { int m;
- printf("Input the number of disks:");
- scanf("%d",&m);
- printf("The steps to moving %3d disks:n",m);
- hanoi(m,'A','B','C');
- }