这题浪费时间了,考虑不周到,存在 越界行为!

include<bits/stdc++.h>

using namespace std;

int main()
{
string str , chart;
getline(cin,str);

int lens = 0;
while(!str.empty())
{
    string  temp;
    int n = str.find(' ');
    temp =   n!= -1 ? str.substr(0,n) :str; 

    if(temp[0] == '"' && temp[temp.length()-1] != '"')
     {
        n = str.find('"',str.find(' '));
        temp  = str.substr(0,n+1);
        n =   temp== str ? n:n+1;
        temp  = temp.substr(1,temp.length()-2);


     }else if(temp[0] == '"' && temp[temp.length()-1] == '"')
    {
        temp  = temp.substr(1,temp.length()-2);
    }

    lens ++;
    chart = chart +  temp +'\n';
    str = n!= -1 ?str.substr(n+1,str.length()): "";
}
cout << lens <<'\n' << chart << endl;
return 0;

}