<문제>
프로그래머스 모바일은 개인정보 보호를 위해 고지서를 보낼 때 고객들의 전화번호의 일부를 가립니다.
전화번호가 문자열 phone_number로 주어졌을 때, 전화번호의 뒷 4자리를 제외한 나머지 숫자를 전부 *으로 가린 문자열을 리턴하는 함수, solution을 완성해주세요.
using System;
public class Solution {
public string solution(string phone_number) {
string answer = "";
int count = 0;
count = phone_number.Length;
phone_number = phone_number.Substring(count-4);
for(int i=0;i<count-4;i++)
{
phone_number = phone_number.Insert(0, "*");
}
answer = phone_number;
return answer;
}
}
'코딩연습 > 프로그래머스 코딩테스트' 카테고리의 다른 글
Lv1. 과일장수 (0) | 2022.11.14 |
---|---|
[프로그래머스]기능개발 (0) | 2021.05.09 |
[오라클] 고양이와 개는 몇 마리 있을까? (0) | 2021.05.08 |
[프로그래머스]문자열 내림차순으로 배치하기 C# (0) | 2021.05.05 |
[프로그래머스] Level1 2016년 (0) | 2021.02.21 |