λ°μν
π€λ¬Έμ ν΄κ²°
-
S2 | μν, 그리λ
μλ² κ΅¬ν λ¬Έμ μ ν΅μ¬μ
μ΅μ΄λ‘ λ§μ΄λμ€κ° λμ¨μκ° λ€μ λͺ¨λ μ«μλ μμλ‘ μ§νν μ μλ€!!
π»μμ€ μ½λ
c = input()
answer = 0
c += '*'
# λ¬Έμ μ ν΅μ¬!! λ§μ΄λμ€κ° μ΅μ΄λ‘ νλ² λμ€λ μκ° λ€μ λͺ¨λ μ«μλ€μ λ§μ΄λμ€λ‘ μ·¨κΈνλ€.!!!
number = ''
operator = '+'
for i in range(len(c)):
if c[i].isdigit():
number += c[i]
else:
if operator == '+':
answer += int(number)
else:
answer -= int(number)
if c[i] == '-':
operator = '-'
number = ''
print(answer)
πλ¬Έμ νμΈ
μΆμ²: BACKJOON ONLINE JUDGE
λ§ν¬: https://www.acmicpc.net/problem/1541
λ°μν
'Algorithm Problem > Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[python] λ°±μ€ - 11279. μ΅λ ν (0) | 2020.10.10 |
---|---|
[python] λ°±μ€ - 10819. μ°¨μ΄λ₯Ό μ΅λλ‘ (0) | 2020.10.09 |
[python] λ°±μ€ - 2133. νμΌ μ±μ°κΈ° (1) | 2020.10.07 |
[python] λ°±μ€ - 11729. νλ Έμ΄ ν μ΄λ μμ (0) | 2020.10.06 |
[python] λ°±μ€ - 1182. λΆλΆμμ΄μ ν© (0) | 2020.10.05 |