L1-059 敲笨钟 (20 分)

又是喜闻乐见的字符串题==。

int main()
{
    int T;
    cin>>T;
    cin.ignore();
    while(T--)
    {
        string s;
        getline(cin,s);

        vector<string> res;
        stringstream ss(s);
        string word;
        bool ok=true;
        while(ss>>word)
        {
            if(word.back() == ',' || word.back() == '.')
            {
                if(word.size() < 4 || word.substr(word.size()-4,3) != "ong")
                {
                    ok=false;
                    break;
                }
            }
            res.pb(word);
        }

        if(ok)
        {
            for(int i=0;i<res.size()-3;i++)
                cout<<res[i]<<' ';
            puts("qiao ben zhong.");
        }
        else puts("Skipped");
    }
    //system("pause");
    return 0;
}
原文地址:https://www.cnblogs.com/fxh0707/p/14690876.html