I have the following python code
for m,n in [(-1,1),(-1,0),(-1,-1)] if 0<=i+m<b and 0<=j+n<l and image[i+m][j+n] == '0']
image is array defined and i and j is also defined.
Following is how I have converted this into C++
std::vector<std::pair<int,int> > direction;
direction.push_back(std::make_pair(-1,1));
direction.push_back(std::make_pair(-1,0));
direction.push_back(std::make_pair(-1,-1));
for ( std::vector<std::pair<int,int> >::iterator itr = direction.begin();
itr != direction.end(); ++itr) {
int m = (*itr).first;
int n = (*itr).second;
if ( (0 <= i + m && i + m < width ) &&
(0 <= j + n && j + n < width ) &&
image[i + m][j + n ] == 0) {
}
Is this conversion correct?
C++code? What kind of data is that? 2D array withchars ?