1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String in = sc.nextLine(); in = in.trim(); if(in.isEmpty()) { System.out.println(0); } else { int count = 1; for(int i=1; i<in.length(); i++) { if(in.charAt(i) == ' ' && in.charAt(i+1) != ' ') count++; } System.out.println(count); } } } | cs |
'프로그래밍 > 백준' 카테고리의 다른 글
8958 OX퀴즈 (0) | 2017.10.14 |
---|---|
2577 숫자의 개수 (0) | 2017.10.14 |
백준 acm 2448 - 별찍기 (11) (0) | 2017.10.06 |
백준 acm 4673 - 셀프 넘버 (0) | 2017.10.01 |
백준 acm 7453 - 합이 0인 네 정수 (0) | 2017.07.30 |