/* 总体思路:解析出参数存放在vector数组中,之后遍历数组打印 需要注意双引号里面的字符串的解析 */ #include<bits/stdc++.h> using namespace std; // 总体思路:解析出参数存放在vector数组中,之后遍历数组打印 int main(){ // 获取输入字符串 string s; getline(cin,s); int len = s.length(); int count=0; vector<string> v; string temp=""; for(int i = 0; i < len; i++){ if(s[i] == '"' && (i != len-1) ){ int j=i+1; while( (j < len) && s[j] != '"'){ j++; } count++; v.push_back(s.substr(i+1, j-i-1)); i=j; }else if(s[i] == ' ' || (i == len - 1) ){ if(i == len - 1){ temp += s[i]; // 最后一个字符 } if(temp != ""){ v.push_back(temp); count++; } temp = ""; }else{ temp += s[i]; } } cout << count << endl; for(auto item : v){ cout << item << endl; } return 0; }