Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

KSI일기장

프로그래머스 369게임 (자바) 본문

JavaAlgorithm

프로그래머스 369게임 (자바)

MyDiaryYo 2023. 12. 14. 14:52

 

 

 

 

class Solution {
    public int solution(int order) {
        int answer = 0;
         String orderSt = order + "";		//int를 String으로 변환
        for(int i=0; i<orderSt.length(); i++) {		//String 각각 하나씩 3, 6, 9랑 일치여부 확인
            if(orderSt.charAt(i) == '3' || orderSt.charAt(i) == '6' || orderSt.charAt(i) == '9') {
                answer++;				//일치하면 answer +1씩 추가
            }
        }
        return answer;
    }
}