"프로그래머스 120826 특정 문자 제거하기"의 두 판 사이의 차이

2번째 줄: 2번째 줄:
{{프로그래머스|레벨=0}}
{{프로그래머스|레벨=0}}
* [[프로그래머스 입문 캘린더]]
* [[프로그래머스 입문 캘린더]]
[[분류: 프로그래머스 입문 캘린더]]
[[분류: 프로그래머스 코딩테스트 입문]]
[[분류: 프로그래머스 코딩테스트 입문]]



2023년 11월 11일 (토) 15:30 판

1 개요

프로그래머스 120826 특정 문자 제거하기

2 C++

#include <string>
#include <vector>

using namespace std;

string solution(string my_string, string letter) {
    char l = letter[0];
    string answer = "";
    for(char& ch: my_string) {
        if(ch != l) {
            answer += ch;
        }
    }
    return answer;
}
#include <string>
#include <vector>
#include <algorithm>

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;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}