Hanoi塔问题。C作为辅助塔座,现要求将塔座A上的的所有圆盘移到塔座B上,并仍按同样顺序叠置。移动圆盘时遵守Hanoi塔问题的移动规则。由此设计出解Hanoi塔问题的递归算法正确的为:( )
A. void hanoi(int n, int A, int C, int B){if (n > 0) {hanoi(n-1,A,C, B);move(n,a,b);hanoi(n-1, C, B, A);}}
B. void hanoi(int n, int A, int B, int C){if (n > 0){hanoi(n-1, A, C, B);move(n,a,b);hanoi(n-1, C, B, A);}}
C. void hanoi(int n, int C, int B, int A){if (n > 0){hanoi(n-1, A, C, B);move(n,a,b);hanoi(n-1, C, B, A);}}
D. void hanoi(int n, int C, int A, int B) {if (n > 0){hanoi(n-1, A, C, B);move(n,a,b);hanoi(n-1, C, B, A);}}