-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmazeio.cpp
More file actions
65 lines (53 loc) · 1.41 KB
/
Copy pathmazeio.cpp
File metadata and controls
65 lines (53 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
mazeio.cpp
Author: Rhea Koparde
Short description of this file:
reads the maze file and prints it out
*/
#include <iostream>
#include "mazeio.h"
using namespace std;
/*************************************************
* read_maze:
* Read the maze from cin into a dynamically allocated array.
*
* Return the pointer to that array.
* Return NULL (a special address) if there is a problem,
* such as integers for the size not found.
*
* We also pass in two pointers to integers. Fill
* the integers pointed to by these arguments
* with the number of rows and columns
* read (the first two input values).
*
*************************************************/
char** read_maze(int* rows, int* cols) {
// FILL THIS IN
cin >> *rows;
cin >> *cols;
char** readMaze =new char* [*rows];
for(int i=0; i<*rows; i++){
readMaze[i]= new char [*cols];
}
for(int i=0; i<(*rows); i++){
for(int j=0; j<(*cols); j++){
cin >> readMaze[i][j];
}
}
return readMaze;
}
/*************************************************
* Print the maze contents to the screen in the
* same format as the input (rows and columns, then
* the maze character grid).
*************************************************/
void print_maze(char** maze, int rows, int cols) {
// FILL THIS IN
cout << rows << " " << cols << endl;
for(int i=0; i<rows; i++){
for(int j=0; j<cols; j++){
cout << maze[i][j];
}
cout << endl;
}
}