C++ vector排序
参考 https://blog.csdn.net/upc_xbt/article/details/53305962
注意:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int num=0;
cin>>num;
string str;
vector<string> word;
while(cin>>str)
{
word.push_back(str);
}
sort(word.begin(),word.end());
for(auto iter=word.cbegin();iter!=word.cend();iter++)
{
cout<<*iter<<endl;
}
}
sort函数不能用cbegin(),即如下是错误的:
sort(word.cbegin(),word.cend());
来源:CSDN
作者:雨过河源忆江南
链接:https://blog.csdn.net/u013656369/article/details/80465197