728x90
주어지는 숫자 n을 숫자 3 또는 3의 배수를 사용하지 않는 마을의 숫자로 변환하는 문제.
.ToString().Contains("")
using System;
public class Solution {
public int solution(int n) {
int answer = 0;
for(int i = 1; i<= n ;i++){
answer++;
while( answer % 3 == 0 || answer.ToString().Contains("3")){
answer++;
}
}
return answer;
}
}
728x90
'제로부터 C# 코딩테스트' 카테고리의 다른 글
프로그래머스 소수 만들기 (0) | 2023.11.29 |
---|---|
프로그래머스 - 정수를 나선형으로 배치하기 (1) | 2023.11.22 |
프로그래머스 - 안전지대 (0) | 2023.11.21 |
프로그래머스 - 광물 캐기 (0) | 2023.11.17 |
프로그래머스 - 특이한 정렬 (1) | 2023.11.14 |