Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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;

image text in transcribedimage text in transcribed

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(col));

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 recursive

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

explain the concept of strategy formulation

Answered: 1 week ago