Question
I just need the pathfinder function: #include #include #include #include std::vector > readIn(std::string file){ std::ifstream fin; fin.open(file); int row,col; fin >> row; fin >> col;
I just need the pathfinder function:
#include
#include
#include
#include
std::vector > readIn(std::string file){
std::ifstream fin;
fin.open(file);
int row,col;
fin >> row;
fin >> col;
std::vector<:vector> > m(row, std::vector
for(int i = 0; i
for(int j = 0 ; j
fin >> m[i][j];
}
}
return m;
}
std::vector > path_finder(const std::vector > & m) {
}
template
void print(const std::vector > & m) {
for(int i = 0; i
for(int j = 0; j
std::cout
}
std::cout
}
std::cout
}
int main() {
std::string fileName;
std::cout
std::cin >> fileName;
std::cout
std::vector > m = readIn(fileName);
std::cout
print(m);
std::cout
return 0;
}
- Write a program that ask the user far a file - That file contains a matrix of numbers (only 1,0 and 1 ) - The first two lines of the file will be the size of the rows and columns - You can assume the data in the file is correct - Your program should stare the values of the matrix af a vectors of int vectors. - Your program should then find a cantinuous path thought the matrix starting at the top left and moving to the botton right 0 The path must have the same number of 1 's and - 1 's. The number of zeros do nat matter - Your program should only move left (col -1), righticol +1 ), up (row -1) and down (row +1). - Your path can only use a pasitian once - If there is such a path in the matrix, that path should be printed to console, using ' A ' for down, 'n' for up, ' > ' for right, ' ' for left, ' x ' where the path ends and '-' for all other positions in the matrix. - You must write a function called path_finder to find the path thought the matrix this function needs be recursiveStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started