-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollections
63 lines (53 loc) · 1008 Bytes
/
Collections
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
vector<int> vi;
for (int i = 0; i < 10; i++)
{
vi.push_back(i);
cout << i;
}
cout << "\n";
for (auto item:vi)
{
cout << item << endl;
}
cout << "^ vi vector" << endl;
vector<string> vs;
for (int i = 0; i < 3; i++)
{
string s;
cin >> s;
vs.push_back(s);
}
string s = "kate";
vs.push_back(s);
for (auto item : vs)
{
cout << item << endl;
}
cout << endl << "int vector vi has " << vi.size() << " elements" << endl;
vi[5] = 3;
vi[6] = -1;
for (auto item : vi)
{
cout << item << " ";
}
cout << endl;
for (unsigned int i = 0; i < vi.size(); i++)
{
cout << vi[i];
}
cout << endl;
for (auto i = begin(vi); i != end(vi); i++)
{
cout << *i;
}
cout << endl;
sort(begin(vs), end(vs));
for (auto item:vs)
{
cout << item << " ";
}
cout << endl;
int threes = count(begin(vi), end(vi), 3);
cout << "vector of ints has " << threes << " elements";
int tees = count(begin(vs[0]), end(vs[0]), 't');
cout << "ffirst word has " << tees << " letter t's";