hi there im a beginner in c++
well ive never used flag before and i was told that i can use flag to this:
i need to fill this shape using flag coding
well here is the code:
#include <iostream>
using namespace std;
int polygon[10][10] =
{
{1,1,1,1,1,1,1,1,1,1},
{1,1,1,2,2,2,2,1,1,1},
{1,1,1,2,1,1,2,1,1,1},
{1,2,2,2,1,1,2,2,2,1},
{1,2,1,1,1,1,1,1,2,1},
{1,2,1,1,1,1,1,1,2,1},
{1,2,1,1,1,1,1,1,2,1},
{1,2,1,1,1,1,1,1,2,1},
{1,2,2,2,2,2,2,2,2,1},
{1,1,1,1,1,1,1,1,1,1},
};
int main()
{
int row,column;
char c='y';
for (int row = 0; row<10; row++)
{
for (int column=0; column <10; column++)
{
if(polygon[row][column]==1) cout << " ";
else if(polygon[row][column]==2)
{
cout << "+";
}
else
cout << " ";
}
cout << "\n";
}
system("pause");
}
this code will print out a squared shape with a top any ideas in how can i fill in this shape using the flag coding
for example in the array i can go like if row and column reached the first 2 it will start filling the shape with a 0 and when it meets the other 2 in the other side it stops and starts a new line till the shape is filled
i dont know how to use flag here i just know the concept
can anyone help please
while( polygon[row][column] == 2)
{
row+=0;
if (row == 2)
{
// in this part i need to go to the next line
}
}
my friend gave me hints of doing something like this in order to fill the shape but i didn't quite get her