Skip to content
Snippets Groups Projects
Commit 0c4e5652 authored by Tamas Bunth's avatar Tamas Bunth
Browse files

Read elements and size of map from file

parent e6b6cd37
No related branches found
No related tags found
No related merge requests found
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
#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;
}
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,
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment