250x250
반응형
Notice
Recent Posts
Recent Comments
Link
목록번호 (1)
N

핸드폰 번호의 뒷 4자리를 제외한 모든 번호를 '*'로 가리면 된다..! for문을 통해 phone_number.size()만큼 돌면서 i의 위치가 뒷 4자리가 아니면 '*'을 answer에 넣어주고, 뒷 4자리이면 번호를 그대로 넣어주면 된다..! 어렵지 않은 문제..! 문자열 길이가 20자 이하라서 for문을 돌려도 된다..! #include #include using namespace std; string solution(string phone_number) { string answer = ""; for(int i = 0; i < phone_number.size(); i++) { if(i < phone_number.size() - 4) answer.push_back('*'); else answer...
프로그래머스 알고리즘/1단계
2020. 4. 29. 09:37