### Checking values of adjacent elements in a 2D array

Hey,

So I currently have a program that can create an array of two dimensions.
ie.
111
111
111

This program then removes random elements from the array using a removal vector.
ie. {2}
101
111
111

What I am now trying to do is check if you have the fifth element (in this case the center element) if the horizontal and adjacent elements are 0.
ie. would return true
101
010
101
but
101
110
101
would return false, because not all four adjacent elements are zero.

I feel like an if statement would likely work but I keep getting parse issues.

My code is below.
 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576`` ``````#include #include #include #include #include #include #include using namespace std; /*------Define Variables-----*/ long int cols; long int rows; long int rem; /*long int verify;*/ long int testver=5; long int myrandom (int i) { return rand()%i;} /*--------------------------------*/ /*----------MAIN PROGRAM----------*/ /*--------------------------------*/ int main() { /*----------User Interface-----------*/ cout<<"Caution: Values larger than 50 might crash program"<> cols; cout<<"Input Columns and press enter:"<>rows; cout<<"What element would you like to verify?"<>verify;*/ long int elements=cols*rows; long int perc[rows][cols]; cout<<"rows="<::iterator it=myvector.begin(); it!=myvector.end(); ++it) cout << ' ' << *it <<","; cout <<"}"<< '\n'; /*----------Builds Array in Memory-----------*/ if (!rem) { for(int x=0;x

Let me know if you have any ideas or suggestions!
Thanks!
Topic archived. No new replies allowed.