Skip to content

Instantly share code, notes, and snippets.

@mojaie
Created December 4, 2011 15:38
Show Gist options
  • Save mojaie/1430475 to your computer and use it in GitHub Desktop.
Save mojaie/1430475 to your computer and use it in GitHub Desktop.
AOJ:0013
import java.util.Scanner;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
Stack<Integer> stack = new Stack<Integer>();
while (scn.hasNext()) {
int n = scn.nextInt();
if (n == 0) {
System.out.println(stack.pop());
} else {
stack.push(n);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment