import java.util.Scanner;
public class Main {
static int queue[] = new int [101];
static int f;
static int r;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int i, j, n = 0;
String arr;
int number[] = new int [101];
n = scan.nextInt();
for (i = 0; i < n; i++) {
arr = scan.next();
if (arr.charAt(0) == 'i') {
int num = scan.nextInt();
push(num);
}
else if (arr.charAt(0) == 'o') {
if (empty()) {
System.out.printf("empty\n");
}
else {
int num = pop();
System.out.printf("%d\n", num);
}
}
else if (arr.charAt(0) == 'c') {
int num = count();
System.out.printf("%d\n", num);
}
}
}
private static int count() {
// TODO Auto-generated method stub
return r - f;
}
private static int pop() {
// TODO Auto-generated method stub
return queue[f++];
}
private static boolean empty() {
// TODO Auto-generated method stub
return f == r;
}
private static void push(int a) {
// TODO Auto-generated method stub
queue[r++] = a;
}
}
http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=970&sca=2070
'정올문제소스코드' 카테고리의 다른 글
1158 : 삽입정렬 (0) | 2021.12.05 |
---|---|
1146 : 선택정렬 (0) | 2021.12.05 |
1102 : 스택 (stack) (0) | 2021.10.31 |
1761 : 숫자 야구 (0) | 2021.10.29 |
3427 : 볼 모으기(balls) (0) | 2021.10.29 |