코딩테스트/프로그래머스 - LV 0
[프로그래머스] 간단한 식 계산하기
웅드
2024. 2. 1. 15:24
- 풀이
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int solution(string binomial) {
stringstream ss(binomial);
int a,b;
char c;
while(ss >> a >> c >> b){
if(c == '+') return a+b;
else if(c == '-') return a-b;
else return a*b;
}
}
반응형