
1. 문제 풀이 아이디어
Replace
메서드를 활용하여 문제를 해결할 수 있다.
2. 나의 정답 코드
StreamReader sr = new(Console.OpenStandardInput());
StreamWriter sw = new(Console.OpenStandardOutput());
int n = int.Parse(sr.ReadLine());
for (int i = 0; i < n; i++)
{
string[] split = sr.ReadLine().Split();
sw.WriteLine(split[0].Replace(split[1], " ").Length);
}
sr.Close();
sw.Close();
3. 정리
Replace
메서드를 활용하여 입력된 문자열에서 클립보드에 저장된 문자열을 공백으로 대체한다.
- 그런 다음, 처리된 문자열의 길이를 출력해 문제를 해결한다.
Share article