String์ผ๋ก ์ ๋ ฅ๋ฐ์ ๋ค์ charAt() ๋ฉ์๋๋ฅผ ํ์ฉํ์ฌ ์กฐ๊ฑด์ ๋ฐ์ ธ๋ณด๊ณ , ํด๋นํ ๋๋ง๋ค ์นด์ดํ ํด์ฃผ๋ฉด ๋๋ ๋งค์ฐ ๊ฐ๋จํ ๋ฌธ์ ์๋ค!
์กฐ๊ฑด์์ ๋๋ ๋ฌธ์ํ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํด์ ํํํ๋๋ฐ, ์์คํค ์ฝ๋๋ฅผ ์๊ณ ์๋ค๋ฉด, ์์คํค ์ฝ๋๋ก ์กฐ๊ฑด์์ ์์ฑํด๋ ๋๋ค.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
//์๋ฌธ์ ๋๋ฌธ์ ์ซ์ ๊ณต๋ฐฑ ๊ฐฏ์ ๊ตฌํ๊ธฐ
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input;
while ((input = br.readLine()) != null) {
int count_small = 0;
int count_large = 0;
int count_num = 0;
int count_space = 0;
for (int i = 0; i < input.length(); i++) {
if ('a' <= input.charAt(i) && input.charAt(i) <= 'z') {
count_small++;
} else if ('A' <= input.charAt(i) && input.charAt(i) <= 'Z') {
count_large++;
} else if ('0' <= input.charAt(i) && input.charAt(i) <= '9') {
count_num++;
} else if (input.charAt(i) == ' ') {
count_space++;
}
}
System.out.println(count_small + " " + count_large + " " + count_num + " " + count_space + " ");
}
}
}