Beispiel #1
0
void biggies_stable_partition(std::vector<std::string> &vs, std::size_t sz)
{
    elimdups(vs);

    auto pivot = stable_partition(vs.begin(), vs.end(), [sz](const std::string& s)
            {return s.size() >= sz;});

    for (auto it = vs.cbegin(); it != pivot; ++it)
        std::cout << *it << " ";
}
Beispiel #2
0
int main()
{
    std::vector<std::string> v{
        "1234", "1234", "1234", "Hi", "alan", "wang"
    };
    elimdups(v);
    std::stable_sort(v.begin(), v.end(), is_shorter);
    std::cout << "ex10.11 :\n";
    println(v);

    return 0;
}
Beispiel #3
0
int main()
{
    //! ex 10.6
    std::vector<int> v{1,2,3,4,5,6,7,8,9};
    std::fill_n(v.begin(),v.size(),0);
    std::cout << "ex10.6:\n";
    println(v);

    //! ex 10.9
    std::vector<std::string> vs{"a","v","a","s","a","a","a"};
    std::cout << "ex 10.9:\n";
    elimdups(vs);
    return 0;
}
Beispiel #4
0
int main(int argc, char *argv[])
{
    std::vector<std::string> v;
    std::string str;
    
    while(std::cin >> str) {
        v.push_back(str);
    }
    
    elimdups(v);
    stable_sort(v.begin(), v.end(), isShorter);

    for (auto a : v) {
        std::cout << a << " ";
    }
    std::cout << std::endl;
    
    return EXIT_SUCCESS;
}