题解 | #参数解析#
参数解析
http://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
import java.util.*;
import java.io.*;
public class Main{
public static void main(String [] args)throws Exception{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str = bf.readLine();
int count=1;
boolean b = false;
StringBuilder sb = new StringBuilder();
for(int i=0; i<str.length();i++){
char x = str.charAt(i);
if(x == '\"' && !b){//第一个引号
b = true;
continue;
}else if(x == '\"' && b){//第二个引号
b= false;
continue;
}else if(x == ' ' && !b){//有空格且不在引号内
count++;
sb.append("\n");
continue;
}
sb.append(x);
}
System.out.println(count);
System.out.println(sb);
}
}