Created
December 4, 2011 15:38
-
-
Save mojaie/1430475 to your computer and use it in GitHub Desktop.
AOJ:0013
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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