标签:style blog color io ar 问题 div log
模拟汉诺塔的移动过程,CC答案的面向对象的太烦,写个以前学的经典的。
public class Solution { public void move(int n, char a, char b, char c) { if (n == 1) { System.out.println("move from " + a + " to " + c); return; } move(n - 1, a, c, b); move(1, a, b, c); move(n - 1, b, a, c); } public static void main(String[] args) { new Solution().move(3, ‘a‘, ‘b‘, ‘c‘); } }
标签:style blog color io ar 问题 div log
原文地址:http://www.cnblogs.com/jdflyfly/p/3923585.html