hanoi问题

#include <iostream>
#include <cstdio>
using namespace std;
int counter = 1;
int move(int n,int a1,int b1,int c1)
{
    getchar();
    printf("count=%d -> ", counter++);
    printf("%d %c %c %c\n", n, a1, b1, c1);
    if(n==1){
      printf("%c-->%c\n",a1, c1);
    }
   else{
    move(n-1,a1, c1, b1);
    printf("%c-->%c\n",a1, c1);
    move(n-1,b1, a1, c1);
   }
   return 0;
}

int main()
{
    int n;
    printf("input number:\n");
    scanf("%d",&n);
    printf("the step to moving %2d diskes:\n", n);
    move(n,'a','b','c');
    return 0;
}

你可能感兴趣的:(c,input,include)