✔️ 나의 답-> 정답
import java.util.*;
public class Main {
public static int solution(String input){
int answer=0;
Stack<Integer>st = new Stack<>();
for(char x : input.toCharArray()) {
if(x>=48 && x<=57)
st.push((int)(x-'0'));
else {
int result;
int a=st.pop();
int b=st.pop();
switch(x) {
case '+':
result=b+a;
st.push(result);
break;
case '-':
result=b-a;
st.push(result);
break;
case '*':
result=b*a;
st.push(result);
break;
case '/':
result=b/a;
st.push(result);
break;
}
}
}
answer = st.pop();
return answer;
}
public static void main(String[] args){
Scanner kb = new Scanner(System.in);
String input = kb.next();
System.out.println(solution(input));
}
}