解题思路:
(1)字符串解析
#include<iostream>
#include<vector>
using namespace std;
void helper(string &s) {
int i=0;
vector<string> v;
string str="";
while(i<s.length()) {
if(s[i]!=' ' && s[i]!='"') {
str="";
while(i<s.length() && s[i]!=' ' && s[i]!='"') {
str+=s[i++];
}
v.push_back(str);
} else if(s[i]==' ') i++;
else if(s[i]='"') {
i++;
str="";
while(i<s.length() && s[i]!='"') {
str+=s[i++];
}
i++;
v.push_back(str);
}
}
cout<<v.size()<<endl;
for(auto &w:v)
cout<<w<<endl;
return;
}
int main() {
string s;
while(getline(cin,s)) {
helper(s);
}
return 0;
}