Make Unreal REAL.
article thumbnail
Level 0. 간단한 식 계산하기

Level 0. 간단한 식 계산하기 #include #include using namespace std; int solution(string binomial) { istringstream iss(binomial); int a, b; char op; iss >> a >> op >> b; switch (op) { case '+': return a + b; case '-': return a - b; case '*': return a * b; default: return 0; } }

article thumbnail
Level 0. ad 제거하기

Level 0. ad 제거하기 #include #include #include using namespace std; vector solution(vector strArr) { auto new_end = remove_if(strArr.begin(), strArr.end(), [](string& s) { return s.find("ad") != string::npos; }); strArr.erase(new_end, strArr.end()); return strArr; }

article thumbnail
Level 0. 9로 나눈 나머지

Level 0. 9로 나눈 나머지 #include #include using namespace std; int solution(string number) { return accumulate(number.begin(), number.end(), 0, [](int sum, int num) { return sum + num - '0'; }) % 9; }

article thumbnail
Level 0. 문자열 뒤집기

Level 0. 문자열 뒤집기 #include #include using namespace std; string solution(string my_string, int s, int e) { reverse(my_string.begin() + s, my_string.begin() + ++e); return my_string; }

article thumbnail
Level 0. 대소문자 바꿔서 출력하기

Level 0. 대소문자 바꿔서 출력하기 #include #include #include using namespace std; string solution(string s); int main(int argc, char* argv[]) { string s; cin >> s; cout

article thumbnail
Level 0. 문자열 섞기

Level 0. 문자열 섞기 메모리 재할당을 줄이고, 문자열을 하나 더 사용하지 않고 기존 문자열을 재활용하기 위해 아래와 같이 구현했다. #include using namespace std; string solution(string str1, string str2) { size_t n = str1.size(); str1.resize(n * 2); for (int i = n - 1; 0

검색 태그