Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- using namespace std;
- int main() {
- int row, col;
- cin >> row >> col;
- cin.ignore();
- char chr;
- string line;
- vector<vector<char>> matrix;
- for (int i = 0; i < row; i++) {
- getline(cin, line);
- istringstream ss(line);
- vector<char> currentRow;
- while (ss >> chr) {
- currentRow.push_back(chr);
- }
- matrix.push_back(currentRow);
- }
- int counter = 0;
- for (int i = 0; i < row - 1; i++) {
- for (int j = 0; j < col - 1; j++) {
- chr = matrix[i][j];
- if (chr == matrix[i][j + 1] &&
- chr == matrix[i + 1][j] &&
- chr == matrix[i + 1][j + 1]) {
- counter++;
- }
- }
- }
- cout << counter << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement