-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset1.cpp
More file actions
53 lines (49 loc) · 1.02 KB
/
Copy pathset1.cpp
File metadata and controls
53 lines (49 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// main.cpp
// set1
//
// Created by Silly on 14-2-3.
// Copyright (c) 2014年 Silly. All rights reserved.
//
#include <iostream>
#include <set>
using namespace std;
int main(int argc, const char * argv[])
{
set<int> s;
s.insert(8);
s.insert(1);
s.insert(12);
s.insert(5);
s.insert(8);
set<int>::iterator it;
for (it = s.begin(); it != s.end(); it++) {
cout << *it << ' ';
}
cout << endl;
set<int>::reverse_iterator rit;
for (rit = s.rbegin(); rit != s.rend(); rit++) {
cout << *rit << " ";
}
cout << endl;
s.erase(5);
for (rit = s.rbegin(); rit != s.rend(); rit++) {
cout << *rit << ' ';
}
cout << endl;
s.clear();
cout << s.size() << endl;
it = s.find(1);
if (it != s.end()) {
cout << *it << endl;
} else {
cout << "Not find it!" << endl;
}
it = s.find(20);
if (it != s.end()) {
cout << *it << endl;
} else {
cout << "Not find it!" << endl;
}
return 0;
}