Reputation: 61
#include <iostream>
#include <vector>
using namespace std;
void printGrid(const vector <vector <int> > &grid){
for (int row = 0; row < grid.size(); row++)
{
for (int column = 0; column < grid.at(row).size(); column++)
{
if (grid.at(row).at(column) == WALL)
{
printWall();
}
else if (grid.at(row).at(column) == COLOR)
{
printColor();
}
else
{
printEmpty();
}
}
}
}
For this function, I am to take in an input for grid and produce a grid with it like
xxxSxxxxxxxxxxxxxxx
x x
xxxxxxx xxxxxxxxxxx
x x
xxxxxxxxxxxxxxGxxxx
where S is the starting point and G is the ending point.
However, for my function, it output everything on to one line instead of making a nice grid. How can I resolve this? Thank you.
Edit:
const int EMPTY = 1;
const int WALL = 2;
const int COLOR = 3;
const int TO_BE_COLORED = 4;
the variables just give a color by using a different file.
Upvotes: 0
Views: 1969