ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [java] 백준 알고리즘 2577번 숫자의 개수 풀이
    알고리즘/백준 알고리즘 2018. 5. 19. 10:47



    * 풀이 소스


    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
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    public class Baekjoon2577 {
     
        public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            
            /* 들어오는 3개의 값들 총 곱 */
            int inputMultiple = Integer.parseInt(br.readLine()) * Integer.parseInt(br.readLine()) * Integer.parseInt(br.readLine());
            String stringInputMultiple = String.valueOf(inputMultiple);
            
            int[] resultArray = new int[10];
            
            for(int i=0; i<stringInputMultiple.length(); i++) {
                
                switch(String.valueOf(stringInputMultiple.charAt(i))) { // 각 숫자가 나올 때마다 1씩 
                    case "0":
                        resultArray[0+= 1;
                        break;
                    case "1":
                        resultArray[1+= 1;
                        break;
                    case "2":
                        resultArray[2+= 1;
                        break;
                    case "3":
                        resultArray[3+= 1;
                        break;
                    case "4":
                        resultArray[4+= 1;
                        break;
                    case "5":
                        resultArray[5+= 1;
                        break;
                    case "6":
                        resultArray[6+= 1;
                        break;
                    case "7":
                        resultArray[7+= 1;
                        break;
                    case "8":
                        resultArray[8+= 1;
                        break;
                    case "9":
                        resultArray[9+= 1;
                        break;
                        
                }
            }
            
            for(int result : resultArray) {
                bw.write(String.valueOf(result));
                bw.newLine();
            }
            bw.flush();
        }
    }
     
    cs


Designed by Tistory.