diff --git a/input.txt b/input.txt new file mode 100644 index 0000000000000000000000000000000000000000..0a790b06334ebc5df9ee105b249460b11e15a80d --- /dev/null +++ b/input.txt @@ -0,0 +1,10 @@ +5 +1 2 +3 4 5 +2 5 4 +5 3 +3 1 2 +4 1 2 +1 3 5 +1 4 5 +3 2 4 diff --git a/program.cxx b/program.cxx index 61fc74195779a9a43873f251bdfe1109fe69c798..64759d32bd3589547b80cee9f4055885def9dcb5 100644 --- a/program.cxx +++ b/program.cxx @@ -1,25 +1,42 @@ #include <list> #include "processor.hxx" #include "matrix.hxx" +#include <iostream> +#include <fstream> +#include <sstream> -int main() +int main(int argc, char** argv) { - Matrix matrix{5}; + if(argc < 2) + { + std::cerr << "Too few arguments. Expected file path." << std::endl; + return -1; + } + + std::string path{argv[1]}; + + std::ifstream input{path}; + std::string line; + getline(input, line); // size of matrix + size_t nMatrixSize = std::stoi(line); + + Matrix matrix{nMatrixSize}; std::list<Element> els; - els.push_back(Element{ {1, 2} }); - els.push_back(Element{ {3, 4, 5} }); - els.push_back(Element{ {2, 5, 4} }); - els.push_back(Element{ {5, 3} }); - els.push_back(Element{ {3, 1, 2} }); - els.push_back(Element{ {4, 1, 2} }); - els.push_back(Element{ {1, 3, 5} }); - els.push_back(Element{ {1, 4, 5} }); - els.push_back(Element{ {3, 2, 4} }); + + while( getline( input, line ) ) + { + std::istringstream iss(line); + std::string word; + std::vector<Symbol> symbols; + while(std::getline(iss, word, ' ')) + { + symbols.push_back(std::stoi(word)); + } + els.push_back(Element{symbols}); + } Processor proci{matrix}; proci.process(els); - - return 0; } diff --git a/result.txt b/result.txt new file mode 100644 index 0000000000000000000000000000000000000000..0b3b02dc580b2d11674788a3c49902ba558df9e6 --- /dev/null +++ b/result.txt @@ -0,0 +1,40 @@ + +Alakzatok +========= + +1: háromszög +2: négyzet +3: kör +4: szív +5: hold + + +Megoldás +======== + + _______ +5| 4| 3 1 2 + | | ____ +4| 1| 2| 5 3 + | | | +3| 2| 1| 4| 5| +_______ | | +1 3 5 2| 4| +_______ | | +2 5 4 3| 1| + + +Elemek (bal fölső sarokból kiindulva) +====== + +5, 4, 3 +4, 1, 2, +3, 1, 2, +2, 1, +5, 3, +4, 2, 3 +5, 4, 1, +1, 3, 5, +2, 5, 4, + +