// stack 문제
data = input().split()
print('Input data is ', data)
num = []
numTop = 0
oper = []
operTop = 0
for i in range(len(data)):
if data[i] == '+' or data[i] == '-' or data[i] == '*' or data[i] == '/':
if operTop == 0:
oper.append(data[i])
operTop += 1
else:
v = oper[operTop-1]
p = data[i]
if p == '+' or p == '-':
if v == '+' or v == '-':
oper.append(data[i])
operTop += 1
else:
gv = oper.pop()
operTop -= 1
n2 = num.pop()
numTop -= 1
n1 = num.pop()
numTop -= 1
if gv == '*':
num.append(n1 * n2)
numTop += 1
else:
num.append(n1 // n2)
numTop += 1
oper.append(data[i])
operTop += 1
else: # * /
oper.append(data[i])
operTop += 1
else:
num.append(int(data[i]))
numTop += 1
while True:
if operTop == 0:
break
print(num)
cv = oper.pop()
operTop -= 1
print(cv)
if cv == '+':
n2 = num.pop()
numTop -= 1
n1 = num.pop()
numTop -= 1
num.append(n1 + n2)
numTop += 1
elif cv == '-':
n2 = num.pop()
numTop -= 1
n1 = num.pop()
numTop -= 1
num.append(n1 - n2)
numTop += 1
print(num)
print(oper)
# 1 + 2 - 3
# 1 2 3 - +
// queue 문제
maxSize = 5
queue = [0]*5
front = 0
rear = 0
while True:
v = int(input('Input Choice: '))
if v == 1:
if front == maxSize:
print('Queue is Full')
else:
k = int(input('Data: '))
queue[front] = k
front += 1
elif v == 2:
if rear == front:
print('Queue is Empty')
else:
k = queue[rear]
print('Output data is ', k)
for i in range(4):
queue[i] = queue[i+1]
if i == 4:
queue[i] = 0
# queue[rear] = 0
# rear += 1
# if rear == front:
# rear = front = 0
elif v == 3:
for i in range(maxSize):
print(queue[i], end=' ')
print()
// graph 문제
k = int(input())
pair = int(input())
num=[]
checkPoint = [0]* (k+1)
# def travel( ):
#
for i in range(k+1):
v = []
for j in range(k+1):
v.append(0)
num.append(v)
for i in range(pair):
v = input().split()
vx = int(v[0])
vy = int(v[1])
num[vx][vy] += 1
num[vy][vx] += 1
for i in range(1, pair+2):
for j in range(1, pair+2):
print(num[i][j], end=' ')
print()
# travel(1, , )
#
#
# for i in range(pair):
# for j in i:
#
#
#
# for i in range(k):
# for j in range(k):
# if i==j:
# continue