/*
* 369게임
* 말해야하는 숫자 order가 매개변수로 주어질 때,
* 머쓱이가 쳐야할 박수 횟수를 return 하도록 solution 함수
*
* order result
* 3 1
* 29423 2
*/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public class programmer_0_26 { static int a1 = 333000; static int a2 = 29423; public int solution(int order) { int answer = 0; String[] ar = Integer.toString(order).split(""); for(String i : ar){ if(Integer.parseInt(i)!=0 && Integer.parseInt(i)%3 == 0) answer++; } return answer; } public static void main(String args[]){ programmer_0_26 t = new programmer_0_26(); System.out.println("---------------------------------------"); System.out.println("result = " + t.solution(a1)); System.out.println("---------------------------------------"); // System.out.println("result2 = " + t.solution(a2)); // System.out.println("---------------------------------------"); } } | cs |