import java.util.Scanner; import java.util.List; import java.util.ArrayList; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextLine()) { // 注意 while 处理多个 case String a = in.nextLine(); process(a); } } private static void process(String str) { List<String> list = new ArrayList<>(); for (int i = 0; i < str.length(); i++) { while (i< str.length() && str.charAt(i) == ' ') { i++; continue; } if (str.charAt(i) == '"') { int s = ++i; while (i< str.length() && str.charAt(i) != '"') { i++; } String child = str.substring(s, i); list.add(child); } else { int s = i; while (i< str.length() && str.charAt(i) != ' ') { i++; } String child = str.substring(s, i); list.add(child); } } System.out.println(list.size()); for(String s : list) { System.out.println(s); } } }