Skip to content

Instantly share code, notes, and snippets.

@jayden-lee
Created January 6, 2019 13:49
Show Gist options
  • Save jayden-lee/4f2ec31412b246656eb0ac982c27e821 to your computer and use it in GitHub Desktop.
Save jayden-lee/4f2ec31412b246656eb0ac982c27e821 to your computer and use it in GitHub Desktop.
백준알고리즘 1152번: 단어의 개수
import java.util.Scanner;
/**
* 단어의 개수 문제<br>
* 알고리즘 분류 : 문자열 처리
*
* @author jayden-lee
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String text = scanner.nextLine();
String[] arrStringSplit = text.split(" ");
int count = 0;
for (String str : arrStringSplit) {
if (!str.isEmpty()) {
++count;
}
}
System.out.println(count);
scanner.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment