This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyLinkedList.cpp
80 lines (70 loc) · 1.82 KB
/
MyLinkedList.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Lab 10b, Write And Test The ListedList Class Template
// Programmer: Minos Park
// Editor(s) used: Sublime Text 2
// Compiler(s) used: G++
#include <iostream>
#include <string>
using namespace std;
#include <cstdlib>
#include "LinkedList.h"
static string buf;
LinkedList<int> getElements()
{
LinkedList<int> numbers;
int userIn = 0;
cout << "Type data or \'Q\' to exit: ";
cin >> buf; cin.ignore(1000, 10);
if(buf[0] == 'q' || buf[0] == 'Q')
return numbers;
userIn = atoi(buf.c_str());
while(1)
{
numbers.insert(userIn);
cout << "Type data or \'Q\' to exit: ";
cin >> buf;
cin.ignore(1000, 10);
if(buf[0] == 'q' || buf[0] == 'Q')
return numbers;
userIn = atoi(buf.c_str());
}
return numbers;
}
void searchFor(LinkedList<int> ar)
{
int number;
while(1)
{
cout << endl << "Search value or \'Q\' to exit: ";
cin >> buf;
cin.ignore(1000, 10);
if(buf[0] == 'q' || buf[0] == 'Q')
break;
number = atoi(buf.c_str());
if(ar.find(number))
cout << "==Value " << buf << " found in list." << endl;
else
cout << "==Value not found." << endl;
}
}
int main()
{
// print my name and this assignment's title
cout << "Lab 10b, Write And Test The ListedList Class Template\n";
cout << "Programmer: Minos Park\n";
cout << "Editor(s) used: Sublime Text 2\n";
cout << "Compiler(s) used: G++\n";
cout << "File: " << __FILE__ << endl;
cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
LinkedList<int> nums;
nums = getElements();
if(nums.length() <= 0)
cout << endl << "==The list contains no values" << endl << endl;
else
{
cout << endl << "==The list: " << nums[0];
for(int i = 1; i < (nums.length()); i++)
cout << ", " << nums[i];
}
cout << endl;
searchFor(nums);
}