본문 바로가기
코딩 테스트

2577번 숫자의 개수(자바, java) - 백준 문제풀이

by 주용사 2023. 1. 11.
728x90
import java.io.*;
import java.util.*;

public class Main {
	 //static int ncheck = 0;
	 //static int nnum = 0;
     /* output setting */
      static StringBuilder sb = new StringBuilder();

      public static void main(String[] args) throws IOException {
           /* input reader */
           BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
           //ArrayList<Integer> list = new ArrayList<>();
           
           int a = Integer.parseInt(br.readLine());
           int b = Integer.parseInt(br.readLine());
           int c = Integer.parseInt(br.readLine());
           int[] count = new int[10]; // 각 몇개 씩 있는지 담아온다
           
           int mul = a * b * c;
           String smul = String.valueOf(mul);
           char[] cmul = smul.toCharArray();
           
           for(int ii = 0 ; ii < cmul.length ; ii++)
           {
        	   if(cmul[ii] == '0')
        		   count[0]++;
        	   else if(cmul[ii] == '1')
        		   count[1]++;
        	   else if(cmul[ii] == '2')
        		   count[2]++;
        	   else if(cmul[ii] == '3')
        		   count[3]++;
        	   else if(cmul[ii] == '4')
        		   count[4]++;
        	   else if(cmul[ii] == '5')
        		   count[5]++;
        	   else if(cmul[ii] == '6')
        		   count[6]++;
        	   else if(cmul[ii] == '7')
        		   count[7]++;
        	   else if(cmul[ii] == '8')
        		   count[8]++;
        	   else if(cmul[ii] == '9')
        		   count[9]++;
           }
           
           for(int ii = 0 ; ii < 10 ; ii++)
        	   System.out.println(count[ii]);
        	
           br.close();
        }
  }
728x90