相关疑难解决方法(0)

河内塔递归java

这是我使用递归解决河内塔的Java代码:

/**here is a stack of N disks on the first of three poles (call
them A, B and C) and your job is to move the disks from pole A to pole B without
ever putting a larger disk on top of a smaller disk.*/ 

public class Hanoi {

    public static void main(String[] args) {
        playHanoi (2,"A","B","C");
    }

    //move n disks from position "from" to "to" via "other"
    private static void playHanoi(int n, String from , String other, String …
Run Code Online (Sandbox Code Playgroud)

java recursion

5
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×1

recursion ×1