프로그래머스 120907 OX퀴즈

1 개요[ | ]

프로그래머스 120907 OX퀴즈

2 C++[ | ]

#include <string>
#include <vector>
#include <sstream>
using namespace std;

string solve(string expr) {
    int a, b, c;
    char op, eq;
    stringstream ss(expr);
    ss >> a >> op >> b >> eq >> c;
    int d = (op == '+') ? a + b: a - b;
    return (c==d) ? "O" : "X";
}

vector<string> solution(vector<string> quiz) {
    for(string& el: quiz) {
        el = solve(el);
    }
    return quiz;
}