New Project migration
This commit is contained in:
51
d_linked_list.h
Normal file
51
d_linked_list.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <iostream>
|
||||||
|
#include <random>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class d_linked_list {
|
||||||
|
|
||||||
|
struct Point {
|
||||||
|
private:
|
||||||
|
string name;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
vector<Point*> edges[5];
|
||||||
|
|
||||||
|
Point() : name("Unnamed"), x(0), y(0) {};
|
||||||
|
Point(string new_name, int new_x, int new_y) : name(new_name), x(new_x), y(new_y) {};
|
||||||
|
Point(string new_name, int new_x, int new_y, Point* edge) : name(new_name), x(new_x), y(new_y) {
|
||||||
|
edges->push_back(edge);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
Point* start;
|
||||||
|
Point* end;
|
||||||
|
|
||||||
|
public:
|
||||||
|
//class constructor
|
||||||
|
d_linked_list() : start(nullptr), end(nullptr) {};
|
||||||
|
|
||||||
|
int rand_int() {};
|
||||||
|
void del_all_data(){};
|
||||||
|
void del_element(int){};
|
||||||
|
void insert(int, int, vector<Point*>){};
|
||||||
|
void gen_list(int){};
|
||||||
|
void print_graph(){};
|
||||||
|
|
||||||
|
|
||||||
|
//Setters
|
||||||
|
int rand_int() {
|
||||||
|
random_device rd;
|
||||||
|
mt19937 gen(rd());
|
||||||
|
uniform_int_distribution<int> dist(1, 30);
|
||||||
|
return dist(gen);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mutators
|
||||||
|
|
||||||
|
};
|
||||||
60
main.cpp
Normal file
60
main.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user