-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.cpp
More file actions
60 lines (55 loc) · 1.08 KB
/
temp.cpp
File metadata and controls
60 lines (55 loc) · 1.08 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
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
using namespace std;
void display(string t)
{
cout << t << " ";
}
bool first_that(deque<string> t, string target)
{
bool flag = 0;
for (auto i : t)
if (i == target)
{
cout << i << " ";
flag = 1;
}
return flag;
}
string getLeft(deque<string> &t)
{
string temp = t.front();
t.pop_front();
return temp;
}
string getRight(deque<string> &t)
{
string temp = t.back();
t.pop_back();
return temp;
}
int main()
{
deque<string> dq, temp;
dq.push_front("is");
dq.push_front("this");
dq.push_front("hello");
dq.push_back("a");
dq.push_back("beautiful");
dq.push_back("hello");
dq.push_back("world");
dq.push_back("program");
for (auto i : dq)
display(i);
cout << "\n";
if (!first_that(dq, "hello"))
cout << "No such string found";
cout << "\n";
temp = dq;
for (auto i : dq)
cout << getLeft(temp) << " ";
cout << "\n";
temp = dq;
for (auto i : dq)
cout << getRight(temp) << " ";
cout << "\n";
}