-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashcodeMain.cpp
More file actions
90 lines (74 loc) · 3.63 KB
/
hashcodeMain.cpp
File metadata and controls
90 lines (74 loc) · 3.63 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
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <vector>
#include <string>
#include "./headers/Book.h"
#include "./headers/Library.h"
#include "./headers/Input_Output.h"
#include "./headers/Algorithms.h"
using namespace std;
int main(int argc, char *argv[]) {
// store all argument into a string vector
vector<string> Arguments(argv, argv + argc);
// basic arguments
vector<string> input_files;
// process all arguments
if (Arguments[1] == "-i") {
for (int i = 2; i < argc; i++) {
input_files.push_back(Arguments[i]);
}
}
// check for errors (optional)
if (input_files.size() == 0)
cout << "No input file given" << endl;
else {
cout << "----------------------------------------------" << endl;
for (uint i = 0; i < input_files.size(); i++) {
/*cout << endl << "Printing file to see if it is ok...\n";
print_file(input_files[i]);
cout << "----------------------------" << endl;*/
cout << "\"" << input_files[i] << "\": OK" << endl;
}
cout << "----------------------------------------------" << endl;
}
// Execution for all files
for (uint i = 0; i < input_files.size(); i++) {
// store input files data to variables and structures
int numBooks = -1;
int numLibraries = -1;
int numDays = -1;
vector <Book*> Books ;
vector <Library*> Libraries;
// Store final results for output
vector < pair <int, vector<int>> > Results;
// Read file arguments and store them in the above variables
import_File_Arguments(input_files[i], numBooks, numLibraries, numDays, Books, Libraries);
// ********** NO DANGER, JUST FOR FUN!! ************ //
// ██████╗░░█████╗░███╗░░██╗░██████╗░███████╗██████╗░
// ██╔══██╗██╔══██╗████╗░██║██╔════╝░██╔════╝██╔══██╗
// ██║░░██║███████║██╔██╗██║██║░░██╗░█████╗░░██████╔╝
// ██║░░██║██╔══██║██║╚████║██║░░╚██╗██╔══╝░░██╔══██╗
// ██████╔╝██║░░██║██║░╚███║╚██████╔╝███████╗██║░░██║
// ╚═════╝░╚═╝░░╚═╝╚═╝░░╚══╝░╚═════╝░╚══════╝╚═╝░░╚═╝
// ************************************************** //
cout << "Number of Books:" << numBooks << endl;
cout << "Number of Libraries:" << numLibraries << endl;
cout << "Number of Days:" << numDays << endl;
//printBooks(Books);
//printLibraries(Libraries);
// Run an algorithm for best results
//mainAlgorithm(Books, Libraries, numDays, Results);
// Run another, optimized algorithm
secondAlgorithm(Books, Libraries, numDays, Results, input_files[i]);
// Print results in file
export_Results(input_files[i], Results);
cout << "----------------------------------------------" << endl;
// Delete dynamically allocated structures
for (uint i = 0; i < Books.size(); i++) {
delete Books[i];
}
for (uint i = 0; i < Libraries.size(); i++) {
delete Libraries[i];
}
}
return 0;
}