-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.cpp
63 lines (56 loc) · 1.23 KB
/
api.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
#include <iostream>
#include <stack>
#include <vector>
std::vector<int> write_to_notepad()
{
int number_of_commands_left;
std::cin >> number_of_commands_left;
std::string command, type;
int id;
std::stack<int> deep_stack, shallow_stack;
std::vector<int> notepad;
while (number_of_commands_left-- > 0)
{
std::cin >> command >> type;
if (command == "dziekuje")
{
std::cin >> id;
if (type == "gleboki")
{
deep_stack.push(id);
}
else if (type == "plytki")
{
shallow_stack.push(id);
}
}
else if (command == "prosze")
{
if (type == "gleboki")
{
notepad.push_back(deep_stack.top());
deep_stack.pop();
}
if (type == "plytki")
{
notepad.push_back(shallow_stack.top());
shallow_stack.pop();
}
}
}
return notepad;
}
void print_results(std::vector<int> notepad)
{
for (auto i : notepad)
{
std::cout << i << "\n";
}
}
int main()
{
print_results(
write_to_notepad()
);
return 0;
}