Sum of the count of number of adjacent squares in an M X N grid | C ++ implementation of the above approach ; function to calculate the sum of all cells adjacent value ; Driver program to test above
#include <bits/stdc++.h> NEW_LINE using namespace std ; int sum ( int m , int n ) { return 8 * m * n - 6 * m - 6 * n + 4 ; } int main ( ) { int m = 3 , n = 2 ; cout << sum ( m , n ) ; return 0 ; }