- /*Hanoi.txt*/
- 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');
- (0) }
- void hanoi(int n,char x,char y,char z)
- (1) {
- (2) if(n==1)
- (3) move(1,x,z);
- (4) else{
- (5) hanoi(n-1,x,z,y);
- (6) move(n,x,z);
- (7) hanoi(n-1,y,x,z);
- (8) }
- (9) }
- void move(int h,char c,char f)
- {
- printf("%d:%c--->%cn",h,c,f);
- }