Tower of Hanoi Below is the program to solve the tower of Hanoi problem. The game is  to move all the disks from the first rod  'A' to the last rod 'C' subject to the following constraints. Only one disk may be moved at a time. Each move consists of taking the topmost disk from one of the stacks and placing it on top of another stack or on an empty rod. No disk may be placed on top of a disk that is smaller than it.   To move n discs from peg A to peg C: move n−1 discs from A to B. This leaves disc n alone on peg A move disc n from A to C move n−1 discs from B to C so they sit on disc n     Fill in the blanks below. class Tower {  static int  move(int n, char source, char destination, char auxiliary, int i) {       if (n > 0 ) {           i = move(n - 1, ___a___, ___b___, ___c___, i);          System.out.println(i+ ": Move disk "+n+" from " + source + " to " +  destination );          i = move(n - 1, auxiliary, destination, source, i+1);       } return i; } public static void main(String[] args) {       int numberOfDisks = 4 ;       move(numberOfDisks, 'A', 'C', 'B', 1 ) ;   } } 1: ___a___ 2: ___b___ 3: ___c___匹配题

题目图片
A

source

B

destination

C

auxiliary

登录即可查看完整答案

我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!