使用sstream分割句子!
// 13'51"
#include <bits/stdc++.h>
using namespace std;
vector<string> split(string str, char c)
{
vector<string> res;
istringstream stream(str);
string token;
while(getline(stream,token,c))
res.push_back(token);
return res;
}
bool ong(string str)
{
int n = str.size() - 2;
if(n < 2) return false;
if(str[n] == 'g' && str[n - 1] == 'n' && str[n - 2] == 'o')
return true;
return false;
}
int main()
{
int n;
cin >> n;
cin.ignore();
for(int i = 1; i <= n; ++ i)
{
string str;
getline(cin,str);
auto word = split(str,' ');
int yayun = true;
for(int i = 0; i < word.size(); ++ i)
{
if(word[i].back() == ',')
{
if(ong(word[i]) == false)
{
yayun = false;
break;
}
}
else if(word[i].back() == '.')
{
if(ong(word[i]) == false)
{
yayun = false;
break;
}
else
{
for(int k = 1; k <= 3; ++ k)
word.pop_back();
word.push_back("qiao");
word.push_back("ben");
word.push_back("zhong.");
}
}
}
if(yayun == false) cout << "Skipped\n";
else
for(auto wi : word)
cout << wi << (wi == word.back() ? "\n" : " ");
}
return 0;
}