로딩
티스토리 데이터 처리 중입니다.

(JAVA) 백준 알고리즘 1152 문제 - 단어의 갯수 (문자열)

 (JAVA) 백준 알고리즘 1152 문제 - 단어의 갯수 (문자열)

[단어의 갯수] : 15분 소요 (정답) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import java.util.Scanner; public class Main1152 { //단어의 갯수 public static void main(String[] args) { Scanner sc = new Scanner(System.in); String input = sc.nextLine().trim(); if (input.isEmpty()) { System.out.println(0); } else { System.out.println(input.split(" ").length); } } } Colored by Color Scripter (내가 처음 작성한 답안) - 왜 틀렸는지 모르겠.....