Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class Problem05CountWords {
- public static void main(String[] args) {
- BufferedReader input = new BufferedReader(new InputStreamReader(
- System.in));
- String line;
- int count = 0;
- try {
- while ((line = input.readLine()) != null && line.length() != 0) {
- String[] words = line.split("\\W+");
- count += words.length;
- }
- } catch (IOException e) {
- System.out.println("Tegav si brat");
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment