#include <stdio.h>
#pragma warning (disable:4996)
int main()
{
// 對hanoi函式的宣告
void hanoi(int n,char one,char two,char three);
int m;
printf("input the number of diskes: ");
scanf("%d",&m);
printf("The step to move %d diskes:\n",m);
hanoi(m,'A','B','C');
}
// 定義hanoi函式:將n個盤從one座借助two座,移到three座
void hanoi(int n,char one,char two,char three)
{
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);
}
uj5u.com熱心網友回復:
i函式宣告要放到main的外邊去轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/67669.html
標籤:基礎類
