[C++ primer] ff

文章目录

他## 谷歌

那你

#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;
}
上一篇:Linux 正则表达式


下一篇:java版spring cloud+spring boot+redis社交电子商务平台(十三)springboot集成spring cache