로딩
요청 처리 중입니다...

BOJ(백준) 1541 - 잃어버린 괄호

 BOJ(백준) 1541 - 잃어버린 괄호

정규식 읽힐겸, 다시 한 번 풀어봄 #include #include #include int main() { std::string line; const std::regex kLineRegex(R"(([0-9]+)|([+-]))", std::regex::optimize); std::smatch line_match; int sum = 0; bool sign_flag = true; std::cin >> line; while(std::regex_search(line, line_match, kLineRegex)) { int val = 0; if (line_match[1].str().empty() == false) // number { val = std::stoi(line_match[1].str()); } else if (sign_flag) { if (line_match[2].str().front() == '-') sign_flag = false...