Language: C++

#include <bits/stdc++.h>
using namespace std;

void my_reverse(int **cell, int i, int j) {
	if (cell[i][j] == 0) {
		cell[i][j] = 1;
	} else {
		cell[i][j] = 0;
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	int cell[N+1][M+1];
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (j-1 >= 1) {
				my_reverse(cell, i, j-1);
				if (i-1 >= 1) {
					my_reverse(cell, i-1, j-1);
				}
				if (i+1 <= N) {
					my_reverse(cell, i+1, j-1);
				}
			}
			if (i-1 >= 1) {
				my_reverse(cell, i-1, j);
			}
			if (i+1 <= M) {
				my_reverse(cell, i+1, j);
			}

			if (j+1 <= M) {
				my_reverse(i, j+1);
				if (i-1 >= 1) {
					my_reverse(cell, i-1, j+1);
				}
				if (i+1 <= N) {
					my_reverse(cell, i+1, j+1);
				}
			}
		}
	}

	int sum = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			sum += cell[i][j];
		}
	}

	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:44: error: cannot convert 'int (*)[(M + 1)]' to 'int**'
   19 |                                 my_reverse(cell, i, j-1);
      |                                            ^~~~
      |                                            |
      |                                            int (*)[(M + 1)]
a.cc:4:23: note:   initializing argument 1 of 'void my_reverse(int**, int, int)'
    4 | void my_reverse(int **cell, int i, int j) {
      |                 ~~~~~~^~~~
a.cc:21:52: error: cannot convert 'int (*)[(M + 1)]' to 'int**'
   21 |                                         my_reverse(cell, i-1, j-1);
      |                                                    ^~~~
      |                                                    |
      |                                                    int (*)[(M + 1)]
a.cc:4:23: note:   initializing argument 1 of 'void my_reverse(int**, int, int)'
    4 | void my_reverse(int **cell, int i, int j) {
      |                 ~~~~~~^~~~
a.cc:24:52: error: cannot convert 'int (*)[(M + 1)]' to 'int**'
   24 |                                         my_reverse(cell, i+1, j-1);
      |                                                    ^~~~
      |                                                    |
      |                                                    int (*)[(M + 1)]
a.cc:4:23: note:   initializing argument 1 of 'void my_reverse(int**, int, int)'
    4 | void my_reverse(int **cell, int i, int j) {
      |                 ~~~~~~^~~~
a.cc:28:44: error: cannot convert 'int (*)[(M + 1)]' to 'int**'
   28 |                                 my_reverse(cell, i-1, j);
      |                                            ^~~~
      |                                            |
      |                                            int (*)[(M + 1)]
a.cc:4:23: note:   initializing argument 1 of 'void my_reverse(int**, int, int)'
    4 | void my_reverse(int **cell, int i, int j) {
      |                 ~~~~~~^~~~
a.cc:31:44: error: cannot convert 'int (*)[(M + 1)]' to 'int**'
   31 |                                 my_reverse(cell, i+1, j);
      |                                            ^~~~
      |                                            |
      |                                            int (*)[(M + 1)]
a.cc:4:23: note:   initializing argument 1 of 'void my_reverse(int**, int, int)'
    4 | void my_reverse(int **cell, int i, int j) {
      |                 ~~~~~~^~~~
a.cc:35:44: error: invalid conversion from 'int' to 'int**' [-fpermissive]
   35 |                                 my_reverse(i, j+1);
      |                                            ^
      |                                            |
      |                                            int
a.cc:35:43: error: too few arguments to function 'void my_reverse(int**, int, int)'
   35 |                                 my_reverse(i, j+1);
      |                                 ~~~~~~~~~~^~~~~~~~
a.cc:4:6: note: declared here
    4 | void my_reverse(int **cell, int i, int j) {
      |      ^~~~~~~~~~
a.cc:37:52: error: cannot convert 'int (*)[(M + 1)]' to 'int**'
   37 |                                         my_reverse(cell, i-1, j+1);
      |                                                    ^~~~
      |                                                    |
      |                                                    int (*)[(M + 1)]
a.cc:4:23: note:   initializing argument 1 of 'void my_reverse(int**, int, int)'
    4 | void my_reverse(int **cell, int i, int j) {
      |                 ~~~~~~^~~~
a.cc:40:52: error: cannot convert 'int (*)[(M + 1)]' to 'int**'
   40 |                                         my_reverse(cell, i+1, j+1);
      |                                                    ^~~~
      |                                                    |
      |                                                    int (*)[(M + 1)]
a.cc:4:23: note:   initializing argument 1 of 'void my_reverse(int**, int, int)'
    4 | void my_reverse(int **cell, int i, int j) {
      |                 ~~~~~~^~~~