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());