Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char asd[10][10];
- void flood(int x, int y)
- {
- if (x<0 || y<0 || x > 9 || y > 9) return;
- if (asd[x][y] != '0') return;
- if (asd[x][y] == '0') asd[x][y] = 'p';
- flood(x-1, y);
- flood(x+1, y);
- flood(x, y+1);
- flood(x, y-1);
- }
- int main()
- {
- int X; // X coordinate of the cell to fill
- int Y; // Y coordinate of the cell to fill
- cin >> X >> Y; cin.ignore();
- int width;
- cin >> width; cin.ignore();
- int height;
- cin >> height; cin.ignore();
- for (int i = 0; i < height; i++) {
- string row; // One row of the map
- getline(cin, row);
- for (int j = 0; j < row.size();++j) asd[i][j] = row[j];
- }
- flood(X,Y);
- int count = 0;
- for (int i = 0; i < 10; ++i)
- for (int j = 0; j < 10; ++j) if (asd[i][j] == 'p') count++;
- // Write an action using cout. DON'T FORGET THE "<< endl"
- // To debug: cerr << "Debug messages..." << endl;
- cout << count << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement