알고리즘/스택 (2) 썸네일형 리스트형 자바 | 백준 | 1874 | 스택 수열 | intValue() Solution 불가능한 경우: 스택의 peek()값이 큐의 peek() 값 보다 클 때 queue의 Integer값과 stk의 Integer값의 범위가 -128~127이 아닐 때, 비교 연산이 불가능하다. → intValue() - Returns the value of this Integer as an int. → stk.peek().intValue(), queue.peek().intValue() // 1874, 스택 수열 package BOJ; import java.io.*; import java.util.*; public class BOJ_1874 { public static void main(String[] args) throws IOException { // TODO Auto-generated .. 파이썬 | 백준 | 1935 | 후위 표기식2 | 소수 둘째자리까지 출력 solution 1. 스택 이용 → 연산자면 pop() 두 번 2. print('%.2f' % n) : 소수 둘째 자리까지 출력 # 1395, 후위 표기식 2 import sys from collections import deque n = int(sys.stdin.readline()) ex = deque() ex.extend(list(sys.stdin.readline().rstrip())) num = [] for _ in range(n): num.append(int(sys.stdin.readline())) tmp = [] res = 0 while ex: x = ex.popleft() if x == '+' or x == '-' or x == '*' or x == '/': a = tmp.pop() b = t.. 이전 1 다음