🐣 알고리즘 삐약/💻 백준 삐약

27 삐약 : 백준 10808[바킹독 문제 풀이 | 배열 | JAVA]

우주수첩 2023. 10. 10. 16:06
728x90

https://www.acmicpc.net/problem/10808

 

10808번: 알파벳 개수

단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다.

www.acmicpc.net

 

 

package Array;
import java.util.*;
public class BOJ_10808 {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] count = new int[26];

        for(char c: s.toCharArray()){
            int index = c -97;
            count[index] +=1;
        }

        for(int i:count){
            System.out.print(i);
            System.out.print(" ");
        }
    }
}

 

 

 


 

728x90