자바 하노이의 탑 예제
12345678910111213141516171819public class Hanoi { public static int cnt = 0; public static void move(char a, char b, char c, int n) { if ( n==0 ) { return; } else { move(a, c, b, n-1); System.out.println(a + "->" + c); cnt++; move(b, a, c, n-1); } } public static void main(String[] args) { move('a', 'b', 'c', 3); System.out.println(cnt++); }}Colored by Color Scriptercs