-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.cpp
96 lines (78 loc) · 1.78 KB
/
input.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
using namespace std;
typedef int Algorithm;
class IntNode{
public:
Algorithm kadane;
Algorithm divCon;
Algorithm brute;
IntNode* next;
friend class IntLinkedList;
};
class IntLinkedList{
public:
IntLinkedList();
~IntLinkedList();
bool isEmpty()const;
const int num(); //prints front element
void addFront(const int& a, const int& b, const int& c);
void removeFront();
friend ostream& operator<<(ostream& out, const IntLinkedList& obj);
private:
IntNode* head;
};
IntLinkedList::IntLinkedList() :head(NULL){}
IntLinkedList::~IntLinkedList(){
while(!isEmpty()) removeFront();
}
bool IntLinkedList::isEmpty()const{
return head == NULL;
}
/*
const int& IntLinkedList::front()const{
}
*/
void IntLinkedList::addFront(const int& a, const int& b, const int& c){
IntNode* v = new IntNode;
v ->brute=a;
v ->divCon=b;
v ->kadane=c;
v ->next=head;
head =v;
}
void IntLinkedList::removeFront(){
IntNode* old =head;
head = old->next;
delete old;
}
ostream& operator<<(ostream& out, const IntLinkedList& obj){
IntNode* temp = obj.head;
while(temp !=NULL){
out << temp->brute<<' '<<temp->divCon<<' '<<temp->kadane<<endl;
temp = temp->next;
}
return out;
}
int main (void){
IntLinkedList* data= new IntLinkedList();
ifstream input;
input.open("output.txt");
if(!input){
cerr<<"File Not Found"<<endl;
return -1;
}
int inputSize,alg1,alg2,alg3;
string firstLine;
getline(input,firstLine); //skips first line
input>>inputSize>>alg1>>alg2>>alg3;
while(input){
data ->addFront(alg1,alg2,alg3);
//cout<<alg1<<' '<<alg2<<' '<<alg3<<endl;
input>>inputSize>>alg1>>alg2>>alg3;
}
cout<< *data <<endl;
return 0;
}