谁有汉诺塔c语言源代码?
楼主你好,下面是源代码!望采纳!
/*//////////////////////////////////////////////////////////////*/
/* 汉诺塔问题 */
/*//////////////////////////////////////////////////////////////*/
#include
/* hanoil 子程序,实现将n个盘子从a移动到c */
void hanoil(int n,char a,char b, char c)
{
if(n==1) /* 递归调用的出口,n=1 */
printf(" >> Move Plate No。
%d from Stick %c to Stick %c。 ",n,a,c);
else
{
hanoil(n-1,a,c,b); /* 递归调用 */
printf(" >> Move Plate No。
%d from Stick %c to Stick %c。 ",n,a,c);
hanoil(n-1,b,a,c);
}
}
/****************************** 主程序******************************/
void main()
{
int n;
char a='A';
char b='B';
char c='C';
clrscr();
printf("This is a hanoil program。
Please input number of the plates: ");
scanf("%d",&n);
if(n<=0)
{
puts("n must no less than 1!");
exit(1);
}
puts("The steps of moving plates are:");
hanoil(n,a,b,c);
puts(" Press any key to quit。
。。");
getch();
}。
答:详情>>
答:读指针用来记录文件当前文件之前的读取位置,它指向下一个将要读取的信息项详情>>