C程序实现千年经典问题-hanoi汉诺塔

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
while(1){
int n = 0;
printf("please input integer number:");
scanf("%d",&n);
void hanoi(int n,char one,char two,char three);    //声明hanoi函数
hanoi(n,'A','B','C');
}
system("PAUSE");
return 0;
}
void hanoi( int n,char one,char two,char three){    //定义hanoi函数
void move(char x,char y);    //声明move函数
if(n==1){
move(one , three);
}else{
hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
void move(char x , char y){     //定义move函数 
printf("%c-->%c\n",x,y);
}

posted @ 2013-10-26 10:22  随风运转  阅读(244)  评论(0编辑  收藏  举报