프로그래머스 181865 간단한 식 계산하기

1 개요[ | ]

프로그래머스 181865 간단한 식 계산하기

2 C++[ | ]

#include <string>
#include <vector>
#include <sstream>

using namespace std;

int solution(string binomial) {
    int a, b;
    char op;
    stringstream ss(binomial);
    ss >> a >> op >> b;
    switch(op) {
        case '+': return a+b;
        case '-': return a-b;
        case '*': return a*b;
    }
    return -9999;
}