일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- docker
- plugin
- aggs
- sort
- aggregation
- matplotlib
- high level client
- License
- license delete
- 파이썬
- licence delete curl
- Test
- 900gle
- Elasticsearch
- Kafka
- zip 암호화
- analyzer test
- API
- zip 파일 암호화
- query
- 차트
- Mac
- springboot
- flask
- TensorFlow
- token filter test
- MySQL
- Python
- Java
- ELASTIC
Archives
- Today
- Total
개발잡부
[groom] Stack 본문
반응형
package kr.co.doo.cote.groom;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;
public class Stackk {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int end = Integer.parseInt(st.nextToken());
int sSize = Integer.parseInt(st.nextToken());
Stack<String> stack = new Stack<>();
for (int i = 0; i < end; i++) {
StringTokenizer stringTokenizer = new StringTokenizer(br.readLine());
String cmd = stringTokenizer.nextToken();
String num = "";
if (stringTokenizer.hasMoreTokens()) {
num = stringTokenizer.nextToken();
}
if (stack.size() == 0 && cmd.equals("pop")) {
System.out.println("Underflow");
} else if (cmd.equals("pop")) {
System.out.println(stack.pop());
}
if (stack.size() >= sSize && cmd.equals("push")) {
System.out.println("Overflow");
} else if (cmd.equals("push")) {
stack.push(num);
}
}
}
}
반응형
'이직 > groom' 카테고리의 다른 글
[groom] M배 배열 (0) | 2023.05.15 |
---|---|
[groom] Queue (0) | 2023.05.15 |
[groom] 8진수 계산기 (0) | 2023.05.15 |
[groom] 수열 - 피보나치의 수 (0) | 2023.05.13 |
[groom] 거스름돈 (0) | 2023.05.10 |
Comments