-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (71 loc) · 1.58 KB
/
main.cpp
File metadata and controls
73 lines (71 loc) · 1.58 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
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "Defines.hpp"
#include "easyfind.hpp"
#include <cstdlib>
#include <ctime>
#include <deque>
#include <list>
#include <vector>
int
main ()
{
print (YELLOW_BOLD TITTLE "CPP Module 08 - ex00" RESET);
std::srand (std::time (0));
{
print (
GREEN SUB_TITTLE
"easyfind() must throw an exception if element is not found\n" RESET);
std::deque<int> deq;
for (int i = 0; i < 10; i++)
deq.push_back (i);
try
{
print (YELLOW "Element found: " RESET << *easyfind (deq, 500));
}
catch (std::exception &e)
{
print (e.what ());
}
}
{
print (GREEN SUB_TITTLE "easyfind() working with a list\n" RESET);
std::list<int> lst;
for (int i = -10; i < 0; i++)
lst.push_back (i);
try
{
print (YELLOW "Element found: " RESET << *easyfind (lst, -4));
}
catch (std::exception &e)
{
print (e.what ());
}
}
{
print (GREEN SUB_TITTLE "easyfind() working with a deque\n" RESET);
std::deque<int> deq;
for (int i = 200; i < 210; i++)
deq.push_back (i);
try
{
print (YELLOW "Element found: " RESET << *easyfind (deq, 209));
}
catch (std::exception &e)
{
print (e.what ());
}
}
{
print (GREEN SUB_TITTLE "easyfind() working with a vector\n" RESET);
std::vector<int> vec;
for (int i = 910; i < 1000; i++)
vec.push_back (i);
try
{
print (YELLOW "Element found: " RESET << *easyfind (vec, 910));
}
catch (std::exception &e)
{
print (e.what ());
}
}
}