Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String pruebas = sc.nextLine();
- int p = Integer.parseInt(pruebas);
- for (int i = p; i != 0; i--) {
- borrados();
- }
- }
- private static void borrados() {
- String dc = sc.nextLine();
- String[] tempdc = dc.split(" ");
- String op = tempdc[0];
- if (op.equals("+")) {
- int num = Integer.parseInt(tempdc[1]);
- s.push(num);
- }else if (op.equals("-")) {
- if (!s.empty()) {
- System.out.println(s.pop());
- } else {
- System.out.println("empty");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement