public class DataConversion { public static void main(String[] args) { Stack<Integer> stack = new Stack<>(); int num = 24241; while (num > 0) { stack.push(num % 10); num = num / 10; }
while (stack.size() > 0) { System.out.print(stack.pop()); }
System.out.println("--------------------------------"); Deque<Integer> stack1 = new ArrayDeque<>(); int number = 12; while (number > 0) { stack1.push(number % 8); number = number / 8; }
while (stack1.size() > 0) { System.out.print(stack1.pop()); } } }
public class HanoiTest { public static long m = 0;
public static void move(char ch1, long n, char ch2) { System.out.println("move " + n + " from " + ch1 + " to " + ch2); }
public static void hanoi(int n, char A, char B, char C) { //System.out.println("times " + (++m) + " " + n + " " + A + " " + C); if (n == 1) move(A, 1, C); else { hanoi(n-1, A, C, B); move(A, n, C); hanoi(n-1, B, A, C); } }
public class DataConversion { public static void main(String[] args) { Stack<Integer> stack = new Stack<>(); int num = 24241; while (num > 0) { stack.push(num % 10); num = num / 10; }
while (stack.size() > 0) { System.out.print(stack.pop()); }
System.out.println("--------------------------------"); Deque<Integer> stack1 = new ArrayDeque<>(); int number = 12; while (number > 0) { stack1.push(number % 8); number = number / 8; }
while (stack1.size() > 0) { System.out.print(stack1.pop()); }