小结

multiset 用的就是字典排序

using namespace std;
int main()
{
    int in_n;
    while(cin>>in_n)
    {
        multiset<string> out_multiset;
        for(int i=0;i<in_n;i++)
        {
            string temp;
            cin>>temp;
            out_multiset.emplace(temp);
        }
        for(auto &t:out_multiset)
        {
            cout<<t<<endl;
        }
    }
    return 0;
}

小结

这个题解思路比较符合我的预期

  1. 使用find与substr实现字符串分割 2.从后向前遍历vector
using namespace std;
void StringSplit(string in_str,string in_split,vector<string> &res)
{
    if(in_str =="") return;
    string strs = in_str + in_split;
    size_t pos = in_str.find(in_split);
    int step = in_split.size();
    while(pos != strs.npos)
    {
        string temp = strs.substr(0,pos);
        res.push_back(temp);
        strs = strs.substr(pos+step,strs.size());
        pos = strs.find(in_split);
    }
}
int main()
{
    string in_str;
    queue<string> str_que;
    while(getline(cin,in_str))
    {
           vector<string> res;
           StringSplit(in_str," ",res);
           for(int i =res.size()-1;i>=0;i--)
           {
               cout<< res.at(i)<<" "; 
           }
           cout<<endl;
    }
    return 0;
}