--------------------------------
#include <stdio.h>
#include <stdlib.h>
static int count = 0;
int print( char x,char y)
{
printf( "%c ---> %c/n", x, y);
return ++count;
}
void move(int n,char x,char y,char z)
{
int count=0;
if(n==1)
{
print(x,z);
}
else
{
move(n-1,y,x,z);
print(x,z);
//count++;
move(n-1,z,y,x);
// return count;
}
}
void main(void)
{
int m;
printf("输入汉诺塔层数:/n");
scanf("%d",&m);
move(m,'A','B','C');
printf("移动了%d次/n",count);
system("pause");
}