// PinoJonoEsim.java SJ import fi.joensuu.cs.tra.*; public class PinoJonoEsim { public static void main(String[] args) { int N = 10; if (args.length > 0) N = Integer.valueOf(args[0]); boolean tulosta = false; if (args.length > 1) tulosta = true; LinkedStack S = new LinkedStack(); for (int i = 0; i < N; i++) S.push(i); if (tulosta) System.out.println(S); reverse(S); if (tulosta) System.out.println(S); LinkedQueue Q = new LinkedQueue(); for (int i = 0; i < N; i++) Q.offer(i*10); if (tulosta) System.out.println(Q); reverse(Q); if (tulosta) System.out.println(Q); } // main() public static void reverse(LinkedStack S) { LinkedQueue Q = new LinkedQueue(); while (! S.isEmpty()) Q.offer(S.pop()); while (! Q.isEmpty()) S.push(Q.poll()); } public static void reverse(LinkedQueue Q) { LinkedStack S = new LinkedStack(); while (! Q.isEmpty()) S.push(Q.poll()); while (! S.isEmpty()) Q.offer(S.pop()); } } // class TraListMerge