forked from Evandabest/AlgorithmsProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (65 loc) · 1.7 KB
/
Copy pathmain.cpp
File metadata and controls
77 lines (65 loc) · 1.7 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
74
75
76
77
#include "DoublyLList.h"
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
srand(42);
DoublyLList List;
for (int i = 0; i <= 14; i++)
{
List.AddToTail(rand() % 100 + 1);
}
cout << " - Menu: " << "\n"
<< "1. Add a Element." << "\n"
<< "2. Print List Elements." << "\n"
<< "3. Print List Elements in reverese." << "\n"
<< "4. Exit." << "\n";
int Option = 1;
cout << "Select an Option from the menu 1-4: ";
while (Option == 1 || 2 || 3 || 4)
{
cin >> Option;
if (Option == 1)
{
int newelement;
cout << "Option #1 is Adding a element, you choose it: ";
cin >> newelement;
if (cin.fail())
{
cin.clear();
}
else
{
List.AddToTail(newelement);
cout << "\n"
<< "Select another option from the menu: ";
}
}
else if (Option == 2)
{
cout << "Option #2 is List Printout: ";
List.PrintElements();
cout << "\n"
<< "Select another option from the menu: ";
}
else if (Option == 3)
{
cout << "Option #3 is Reverse List Printout: ";
List.PrintReverse();
cout << "\n"
<< "Select another option from the menu: ";
}
else if (Option == 4)
{
cout << " Thanks, Hava a good Day!! " << endl;
break;
}
else
{
cout << " - Invalid Input, Try again later.";
break;
}
}
return 0;
}