文章目录
他## 谷歌
那你
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <list>
using namespace std;
template <typename Sequence>
inline ostream& println(Sequence const& seq)
{
for (auto const& elem : seq)
cout << elem << " ";
cout << endl;
return cout;
}
inline bool is_shorter(std::string const& lhs, std::string const& rhs)
{
return lhs.size() < rhs.size();
}
void elimdups(vector<string> &vs)
{
sort(vs.begin(), vs.end());
auto new_end = unique(vs.begin(), vs.end());
vs.erase(new_end, vs.end());
}
int main()
{
vector<string> v{ "1234", "1234", "1234", "Hi", "alan", "wang" };
elimdups(v);
stable_sort(v.begin(), v.end(), is_shorter);
cout << "ex10.11 :\n";
println(v);
system("pause");
return 0;
}