Created
January 6, 2019 13:49
-
-
Save jayden-lee/4f2ec31412b246656eb0ac982c27e821 to your computer and use it in GitHub Desktop.
백준알고리즘 1152번: 단어의 개수
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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