c语言汉诺塔问题如下:
#include <stdio.h>
char move (char x, char y);
char hanoi(int n,char a, char b, char c);
int main()
{int n;char a,b,c;
a='A';b='B';c='C';
scanf("%d",&n);
hanoi (n,a,b,c);
}
char 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);}
return;
}
char move(char x,char y)
{ printf("%c->%c\n",x,y);}
慕娘9325324
叮当猫咪