#include<stdio.h> #include<stdlib.h> int sum=0; void move(char x,char y) { printf("%c--->%c\n",x,y); sum++; } void hanoi(int n,char a ,char b,char c) { if(n==1) move(a,c); else { hanoi(n-1,a,c,b); move(a,c); hanoi(n-1,b,a,c); } } int main() { int m; printf("input the number of diskes:"); scanf("%d",&m); printf("the step to moving %d diskes:\n"); hanoi(m,'A','B','C'); printf("%d\n",sum); system("pause"); }