汉诺塔小程序
#include"string.h"#include"stdio.h"
char move(char getone,char putone)
{
printf("%c-->%c\n",getone,putone);
}
char hanoi(int n,char one,char two,char three)
{
if(n==1)
move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
main()
{
char haoni(int,char,char,char);
int m=3;
char one,two,three;
one=getchar();two=getchar();three=getchar();
hanoi(m,one,two,three);
}
#include"string.h"
#include"stdio.h"
char move(char getone,char putone)
{
printf("%c-->%c\n",getone,putone);
}
char hanoi(int n,char one,char two,char three)
{
if(n==1)
move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
main()
{
char haoni(int,char,char,char);
int m=3;
char one,two,three;
one=getchar();two=getchar();three=getchar();
hanoi(m,one,two,three);
}
#include"string.h"
#include"stdio.h"
char move(char getone,char putone)
{
printf("%c-->%c\n",getone,putone);
}
char hanoi(int n,char one,char two,char three)
{
if(n==1)
move(one,three);
else
{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
main()
{
char haoni(int,char,char,char);
int m=3;
char one,two,three;
one=getchar();two=getchar();three=getchar();
hanoi(m,one,two,three);
}