Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- //import java.util.Scanner;
- class D702 {
- public static Stack<Integer> S = new Stack<Integer>();
- public static void main(String[] args) {
- Scanner inp = new Scanner(System.in);
- String line;
- int N;
- // Get the number of commands
- N = inp.nextInt();
- // Foreach command, do the processing on the stack.
- for (int i=0; i<N; i++) {
- // Read in the command and process it.
- line = inp.nextLine();
- if (line.equals("TOP")) {
- // DIY
- } else if (line.equals("POP")) {
- // DIY
- } else if (line.equals("SIZE")) {
- // DIY
- } else if (line.startsWith("PUSH")) {
- // Take the integer from the line
- String sNum = line.substring(5);
- int iNum = Integer.parseInt(sNum);
- // System.out.println(iNum);
- // DIY
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement