백준 2577 숫자의 개수(Java)
by 개발자 우디문제보기
정답
package baekjoon.ex_array;
import java.util.Scanner;
public class Q_2577 {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
int C = sc.nextInt();
int mul = A * B * C;
String strMul = mul + "";
int[] cnt = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for (int i = 0; i < strMul.length(); i++) {
switch (Integer.parseInt((strMul.charAt(i)) + "")) {
case 0:
cnt[0]++;
break;
case 1:
cnt[1]++;
break;
case 2:
cnt[2]++;
break;
case 3:
cnt[3]++;
break;
case 4:
cnt[4]++;
break;
case 5:
cnt[5]++;
break;
case 6:
cnt[6]++;
break;
case 7:
cnt[7]++;
break;
case 8:
cnt[8]++;
break;
case 9:
cnt[9]++;
break;
default:
break;
}
}
for (int i = 0; i < cnt.length; i++) {
System.out.println(cnt[i]);
}
sc.close();
}
}
블로그의 정보
우디의 개발스터디
개발자 우디