#include<iostream>
#include<string>
using namespace std;
int k = 0;
string a[50];
string temp;
int main(){
string s;
getline(cin, s);
int position = 0;
while(1){
//cout << "\"y\""<<endl;
int flag = 0;
int tmposition = position;
//cout<<"------------------------------"<<endl;
//cout<<"tmposition = "<<tmposition<<endl;
position = s.find(" ",tmposition);
//cout<<"position = "<<position<<endl;
if(position == s.npos){
temp = s.substr(tmposition);
if(temp[0] == '\"') temp = temp.substr(1,temp.length()-2);
a[k++] = temp;
break;
}
temp = s.substr(tmposition, position - tmposition);
if(temp[0] == '\"'){
position = s.find('\"', position);
temp = temp = s.substr(tmposition + 1, position - tmposition - 1);
//a[k++] = temp;
flag = 1;
}
//cout<<"temp = "<<temp<<endl;
a[k++] = temp;
if(position == s.length() - 1) break;
else if(flag) {
position = position + 2;
continue;
}
position++;
//cout<<"after ++.position = "<<position<<endl;
}
cout<<k<<endl;
for(int i = 0; i < k; i++)
cout<<a[i]<<endl;
return 0;
}
参数解析
最新推荐文章于 2023-03-20 14:39:54 发布