-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lab_08.cpp
52 lines (39 loc) · 1.14 KB
/
Lab_08.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
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
template<typename C>
void printContainer(const string comment, C const& container)
{
cout << comment << " = { ";
for(auto n: container)
{
cout << n << ",";
}
cout << "}; \n";
}
void fnUpperCase(string &str)
{
for(int i=0;i<str.length();i++){
if(str[i] >= 'a' && str[i] <= 'z'){
str[i] = (char)(str[i]-'a' + 'A');
}
}
}
int main()
{
cout << "Create vector vString" << endl;
vector<string> vString {"World","Of","Hello","Programmers","Hello"};
printContainer("vector1",vString);
cout << "1- Use algorithm find() to find the first occurrence of Hello" << endl;
if ()
cout << "key Hello not found" << endl;
else
cout << "key Hello found" << endl;
cout << "2- Use algorithm count() to count occurrences of Hello" << endl;
cout << "Hello is repeated "<< count_hello << " times" << endl;
cout << "3- Use algorithm for_each() to convert every string in the vector to uppercase" << endl;
printContainer("vector1",vString);
return 0;
}