30 lines
762 B
Java
30 lines
762 B
Java
import java.util.Scanner;
|
|||
|
|
|
||
|
|
public class Solution {
|
||
|
|
|
||
|
|
public static void main(String[] args) {
|
||
|
|
/* Read input */
|
||
|
|
Scanner scan = new Scanner(System.in);
|
||
|
|
String s = scan.nextLine();
|
||
|
|
scan.close();
|
||
|
|
|
||
|
|
/* Must trim String to pass test cases. Still unclear why it's necessary */
|
||
|
|
s = s.trim();
|
||
|
|
|
||
|
|
/* Check special cases */
|
||
|
|
if (s.length() == 0) {
|
||
|
|
System.out.println(0);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Split on all non-alphabetic characters */
|
||
|
|
String [] words = s.split("[^a-zA-Z]+");
|
||
|
|
|
||
|
|
/* Print output */
|
||
|
|
System.out.println(words.length);
|
||
|
|
for (String word : words) {
|
||
|
|
System.out.println(word);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|