-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe12.cpp
55 lines (45 loc) · 831 Bytes
/
e12.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
//
// Created by martin on 13/01/2022.
//
#include "../std_lib_facilities.h"
void print_until_s (vector<string> &v, const string &quit)
{
for (const auto &s: v)
{
if (s == quit)
{
return;
}
cout << s << '\n';
}
}
void print_until_ss (vector<string> &v, const string &quit)
{
int seen {0};
for (const auto &s: v)
{
if (s == quit)
{
if (seen == 1)
{
return;
}
else
{
++seen;
}
}
cout << s << '\n';
}
}
int main ()
{
vector<string> sv {"Peter", "Poul", "Bo", "James", "Zoom", "Bike", "James", "Bo", "Tv", "Top"};
print_until_s(sv, "XXX");
cout << "-----------------" << endl;
print_until_s(sv, "James");
cout << "--- ss ---" << endl;
print_until_ss(sv, "XXX");
cout << "-----------------" << endl;
print_until_ss(sv, "James");
}