-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstl_1.cpp
106 lines (90 loc) · 2.35 KB
/
stl_1.cpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//контейнеры stl
#include <iostream>
#include <string>
#include <ctime>
#include <fstream>
#include <vector>
#include <Windows.h>
#include <conio.h>
#include <set>
#include <map>
#include<vector>
#include<fstream>
#include <set>
#include <map>
using namespace std;
class User
{
public:
User(string name, int age) :name(name), age(age) {};
User() {};
void print() {
cout << name << "(" << age << ")" << endl;
}
private:
string name;
int age;
};
int duplicateCount(string str) {
map <char, int> symbols;
for (char c : str) {
if (isalpha(c)) c = tolower(c);
if (symbols.find(c) == symbols.cend()) {
symbols[c] = 0;
}
else {
symbols[c] = 1;
}
}
int sum = 0;
for (auto item : symbols) sum += item.second;
return sum;
}
int main() {
srand(time(NULL));
//что-то вроде массива
/* vector <string > names;
names.push_back("Gffrd");
for (int i = 0; i < names.size(); i++) {
cout<<names[i] << endl;
}
//set сортирует по алфавиту и по возрастанию чисeл и убирает повторяющее, хранит значение
set<string> keys;
keys.insert("A");
keys.insert("D");
keys.insert("B");
for (auto iter = keys.begin();
iter != keys.end(); iter++) {
cout << *iter << endl;
}
//map тоже убирает повторяющее, хранит ключи и значения
map <string, string> capitalis;
capitalis["The world"] = "Mexico";
capitalis["Moscow"] = "Restoraunt";
capitalis["Cosmos"] = "Planet";
for (auto iter = capitalis.begin();
iter != capitalis.end(); iter++) {
cout << iter->first << " - " << iter->second << endl;
}
multimap <string, string> capitalis;
capitalis.insert(pair <string, string>("The world", "Austria"));
for (auto iter = capitalis.begin();
iter != capitalis.end(); iter++) {
cout << iter->first << " - " << iter->second << endl;
} */
map<string, User> sdp;
sdp["assassin"] = User("Ruslan", 15);
sdp["racer"] = User("Viktor", 15);
sdp["astronaut"] = User("Sergey", 16);
sdp["boxer"] = User("Rodion", 15);
set<string> need;
need.insert("racer");
need.insert("astronaut");
vector<User> users;
for (auto item : need) {
if (sdp.find(item) != sdp.cend()) {
users.push_back(sdp[item]);
sdp[item].print();
}
}
}