DiffEreD
1438 / 775 / 95
Регистрация: 21.06.2011
Сообщений: 1,740
|
20.03.2014, 18:57
|
|
Простой пример на С++11: C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| #include <iostream>
#include <iterator>
#include <string>
#include <set>
using std::string;
auto comparer = [](const string& x, const string& y)
{
return x.size() < y.size();
};
using my_set = std::multiset<string, decltype(comparer)>;
using input = std::istream_iterator<string>;
int main()
{
std::cout << "Enter words (Ctrl+Z to stop): >\n";
my_set set {input(std::cin), input(), comparer };
for (auto& i : set) std::cout << i << "\n";
return 0; |
|
0
|