c++ string을 통 특정 문자 제거
·
C++
#include #include using namespace std;string solution(string my_string, string letter) { my_string.erase(remove(my_string.begin(),my_string.end(), letter[0]),my_string.end()); return my_string;}remove(my_string.begin(), my_string.end(), letter[0]): 이 함수는 my_string의 시작부터 끝까지 탐색하면서 letter[0]과 일치하는 모든 문자를 "제거"합니다. 그런데 여기에서 "제거"는 실제로 해당 요소들을 문자열에서 삭제하는 것이 아니라, 문자열의 뒷부분으로 이동시키는 것을 의미합니다. remove..