본문 바로가기
알고리즘 & 자료구조/백준

백준 2577

by 신재권 2021. 7. 7.
import java.util.Scanner;

public class Main2577 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int A = s.nextInt();
		int B = s.nextInt();
		int C = s.nextInt();

		int result = A * B * C;
		int[] cnt = new int[10];
		String answer = result + "";

		int num = 0;

		for (int i = 0; i < answer.length(); i++) {
			for (int j = 0; j < cnt.length; j++) {
				if (j == (answer.charAt(i) - '0')) {
					cnt[j]++;
				}
			}
		}
		for (int i = 0; i < cnt.length; i++)
			System.out.println(cnt[i]);

	}

}

세개 정수의 곱을 문자열로 변환후, chatAt으로 추출해 값을 비교하였다. 문자정수를  숫자 정수로 바꿀라면 문자 '0'을 빼주면 된다.

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 8958  (0) 2021.07.08
백준 3052  (0) 2021.07.07
백준 2562  (0) 2021.07.07
백준 10818  (0) 2021.07.07
백준 1100  (0) 2021.07.04