含若塔递归:
Hanluota(int n,char one ,char two, char three)//把第塔一的盘移到塔三的盘,借助塔二
{
if(n==1) { 从第一个盘子移到第三个盘子;}
Hanluota(n-1,one ,three,two);
从第一个盘子移到第三个盘子;
Hanluota(n-1,two,one ,three);
}
//不要看怎么调用,而要看,第N层与第N-1层之间的关系。
该函数,
含若塔递归:
Hanluota(int n,char one ,char two, char three)//把第塔一的盘移到塔三的盘,借助塔二
{
if(n==1) { 从第一个盘子移到第三个盘子;}
Hanluota(n-1,one ,three,two);
从第一个盘子移到第三个盘子;
Hanluota(n-1,two,one ,three);
}
//不要看怎么调用,而要看,第N层与第N-1层之间的关系。
该函数,
1580
1万+

被折叠的 条评论
为什么被折叠?