Advertisement
jackyhuichunkit

D702 Sample Program

Feb 20th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.*;
  2. //import java.util.Scanner;
  3.  
  4. class D702 {
  5.     public static Stack<Integer> S = new Stack<Integer>();
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner inp = new Scanner(System.in);
  9.         String line;
  10.         int N;
  11.  
  12.         // Get the number of commands
  13.         N = inp.nextInt();
  14.  
  15.         // Foreach command, do the processing on the stack.
  16.         for (int i=0; i<N; i++) {
  17.             // Read in the command and process it.
  18.             line = inp.nextLine();
  19.             if (line.equals("TOP")) {
  20.                 // DIY
  21.  
  22.             } else if (line.equals("POP")) {
  23.                 // DIY
  24.  
  25.             } else if (line.equals("SIZE")) {
  26.                 // DIY
  27.  
  28.             } else if (line.startsWith("PUSH")) {
  29.                 // Take the integer from the line
  30.                 String sNum = line.substring(5);
  31.                 int iNum = Integer.parseInt(sNum);
  32.                 // System.out.println(iNum);
  33.                 // DIY
  34.                
  35.             }
  36.  
  37.  
  38.  
  39.         }
  40.  
  41.     }
  42.  
  43.  
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement