본문 바로가기
알고리즘풀이/백준-자바

[백준/JAVA] 2577번 숫자의 개수

by 이얏호이야호 2020. 7. 21.

import java.util.Scanner;


public class Main {

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

int input1, input2, input3, result;

String[] arr;

int[] count = new int[10];


input1 = in.nextInt();

input2 = in.nextInt();

input3 = in.nextInt();

result = input1 * input2 * input3;

arr = Integer.toString(result).split("");

for (int i = 0; i < arr.length; i++) {

if(arr[i].equals("0")) {

count[0]++;

}else if(arr[i].equals("1")) {

count[1]++;

}else if(arr[i].equals("2")) {

count[2]++;

}else if(arr[i].equals("3")) {

count[3]++;

}else if(arr[i].equals("4")) {

count[4]++;

}else if(arr[i].equals("5")) {

count[5]++;

}else if(arr[i].equals("6")) {

count[6]++;

}else if(arr[i].equals("7")) {

count[7]++;

}else if(arr[i].equals("8")) {

count[8]++;

}else if(arr[i].equals("9")) {

count[9]++;

}

}

for(int i=0;i<count.length;i++) {

System.out.println(count[i]);

}



}

}

더 많은 백준 코드가 보고 싶다면 ?  https://chuinggun.tistory.com/category/%EB%B0%B1%EC%A4%80


댓글