61 lines
1.0 KiB
C++
61 lines
1.0 KiB
C++
// Linked List Cycle.cpp :
|
|
|
|
#include "d_linked_list.h"
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
d_linked_list list = d_linked_list();
|
|
string input;
|
|
while (true) {
|
|
cout
|
|
<<"Instructions: " << endl
|
|
<< "pop" << endl
|
|
<< "push" << endl
|
|
<< "delete" << endl
|
|
<< "insert" << endl
|
|
<< "generate" << endl
|
|
<< "sort" << endl
|
|
<< "print" << endl
|
|
<< "erase" << endl
|
|
<< "quit" << endl
|
|
<< ": ";
|
|
cin >> input;
|
|
cout << endl;
|
|
|
|
if (input == "pop") {
|
|
list.pop();
|
|
}
|
|
else if (input == "push") {
|
|
cout << "Input: ";
|
|
int target;
|
|
cin >> target;
|
|
list.push(target);
|
|
}
|
|
else if (input == "delete") {
|
|
int target;
|
|
cout << "Enter element: ";
|
|
cin >> target;
|
|
list.del_element(target);
|
|
}
|
|
else if (input == "quit") {
|
|
return 0;
|
|
}
|
|
else if (input == "print") {
|
|
list.print_data();
|
|
|
|
}
|
|
else if (input == "erase") {
|
|
list.del_all_data();
|
|
input = "";
|
|
}
|
|
else if (input == "generate") {
|
|
int num_items;
|
|
cout << "Enter number of items: ";
|
|
cin >> num_items;
|
|
list.gen_list(num_items);
|
|
}
|
|
}
|
|
}
|
|
|