fault Paragraph Styl A A Liberation Serif 7 pt BIU S A A LA-AO - 10 11 12 13 Winclude Winclude 0 && y= WIDTH| y >= HEIGHT|| Imaze[yx]) { %3D return; if (x dest x && y= dest y) std:cout << path std::cout <

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

how can this code display only for these paths, what needs to be changed c++

Window
Help
T ー国▼
Default Paragraph Styl
Liberation Serif
7 pt
BIU S
A A, LA
7
8.
6.
10
11
12
13
14
15
#include <iostream>
#include <string>
using namespace std;
const int WIDTH = 5;
const int HEIGHT = 5;
int x_cor[] = {, 0, 1, -1};
int y_cor[] = {1, -1, 0, 0};
bool checkCoordinates(int x, int y)
{
return (x >= 0 && x < HEIGHT && y >= 0 && y<WIDTH);
17
void check(int x, int y, int dest_x, int dest_y,
int (&maze)[HEIGHT][WIDTH], std::string &path, int (&visited)[HEIGHT|[WIDTH])
// if (x<0 || y < 0 || x >= WIDTH| y >= HEIGHT || !maze[y][x]) {
return;
// }
if (x == dest_x &&y == dest _y)
{
std::cout << path;
std::cout << x <<","<<y<< \n';
return;
vi sited[x][y] = 1;
int len = path.size();
path += (char)('O' + x);
path +=',;
path += (char)('0" + y);
path += " > ".
for (int k = 0; k < 4; k++)
int newi = x + x_cor[k];|
、田
O AT
File Edit
View
Insert
Format Styles Table
Form
Tools Window Help
開,
Default Paragraph Styl
A Liberation Serif
7 pt
BIU
A A, L A
2
10
12
int newi = x+ x_cor[k];
int newj = y + y_cor[k];
if (checkCoordinates(newi, newj) && maze[newi][newj] == 1 && visited[newi][newj] ==0)
11
13
14
16
check(newi, newj, dest_x, dest_ y, maze, path, visited);
visited[newi][newj] = 0;
path.resize(len);
int main()
int maze[HEIGHT][WIDTH] = {
{1, 1, 1, 1, 1},
{1, 1, 1, 0, 1},
{0, 1, 1, 0, 1},
{0, 1, 0,0, 1},
{0, 1, 1, 1, 1}};
int visited[HEIGHT][WIDTH];
for (int i = 0; i<HEIGHT; i++)
for (int j = 0; j <WIDTH; j++)
vi sited[i][j] = 0;
std:string path;
check(0, 0, 4, 4, maze, path, visited);
return 0,
Transcribed Image Text:Window Help T ー国▼ Default Paragraph Styl Liberation Serif 7 pt BIU S A A, LA 7 8. 6. 10 11 12 13 14 15 #include <iostream> #include <string> using namespace std; const int WIDTH = 5; const int HEIGHT = 5; int x_cor[] = {, 0, 1, -1}; int y_cor[] = {1, -1, 0, 0}; bool checkCoordinates(int x, int y) { return (x >= 0 && x < HEIGHT && y >= 0 && y<WIDTH); 17 void check(int x, int y, int dest_x, int dest_y, int (&maze)[HEIGHT][WIDTH], std::string &path, int (&visited)[HEIGHT|[WIDTH]) // if (x<0 || y < 0 || x >= WIDTH| y >= HEIGHT || !maze[y][x]) { return; // } if (x == dest_x &&y == dest _y) { std::cout << path; std::cout << x <<","<<y<< \n'; return; vi sited[x][y] = 1; int len = path.size(); path += (char)('O' + x); path +=',; path += (char)('0" + y); path += " > ". for (int k = 0; k < 4; k++) int newi = x + x_cor[k];| 、田 O AT File Edit View Insert Format Styles Table Form Tools Window Help 開, Default Paragraph Styl A Liberation Serif 7 pt BIU A A, L A 2 10 12 int newi = x+ x_cor[k]; int newj = y + y_cor[k]; if (checkCoordinates(newi, newj) && maze[newi][newj] == 1 && visited[newi][newj] ==0) 11 13 14 16 check(newi, newj, dest_x, dest_ y, maze, path, visited); visited[newi][newj] = 0; path.resize(len); int main() int maze[HEIGHT][WIDTH] = { {1, 1, 1, 1, 1}, {1, 1, 1, 0, 1}, {0, 1, 1, 0, 1}, {0, 1, 0,0, 1}, {0, 1, 1, 1, 1}}; int visited[HEIGHT][WIDTH]; for (int i = 0; i<HEIGHT; i++) for (int j = 0; j <WIDTH; j++) vi sited[i][j] = 0; std:string path; check(0, 0, 4, 4, maze, path, visited); return 0,
1, 1, 1, 1, 1 },
1, 1,, 0, 1 },
8, 1, 8, 1 },
0, 1, 0, e, 1 },
},
1, 1, 1, 0,
1, 1,
1, 1, 1, 1 },
1, а, 1 },
0,
1, 1, 1, 1 },
, 1, 0, 1 },
1, в, 1 },
0, , в, а, 1 },
в, 1. 1, 1, 1 }
},
в, 1, 1, в,
1, 1:
},
в, 1, 8, в,
в, 1, 1, 1, 1}
1, в, 1 },
в, в, 1 },
0,
1, 1, 1, 1 },
1, 1, 1, е, 1 },
0, 5
в, в, 1 },
0,
,8, 1 },
Transcribed Image Text:1, 1, 1, 1, 1 }, 1, 1,, 0, 1 }, 8, 1, 8, 1 }, 0, 1, 0, e, 1 }, }, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 }, 1, а, 1 }, 0, 1, 1, 1, 1 }, , 1, 0, 1 }, 1, в, 1 }, 0, , в, а, 1 }, в, 1. 1, 1, 1 } }, в, 1, 1, в, 1, 1: }, в, 1, 8, в, в, 1, 1, 1, 1} 1, в, 1 }, в, в, 1 }, 0, 1, 1, 1, 1 }, 1, 1, 1, е, 1 }, 0, 5 в, в, 1 }, 0, ,8, 1 },
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY