Centrosymmetric Matrix | CPP Program to check whether given matrix is centrosymmetric or not . ; Finding the middle row of the matrix ; for each row upto middle row . ; If each element and its corresponding element is not equal then return false . ; Driven Program
#include <bits/stdc++.h> NEW_LINE using namespace std ; #define N  3 NEW_LINE bool checkCentrosymmetricted ( int n , int m [ N ] [ N ] ) { int mid_row ; if ( n & 1 ) mid_row = n / 2 + 1 ; else mid_row = n / 2 ; for ( int i = 0 ; i < mid_row ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( m [ i ] [ j ] != m [ n - i - 1 ] [ n - j - 1 ] ) return false ; } } return true ; } int main ( ) { int n = 3 ; int m [ N ] [ N ] = { { 1 , 3 , 5 } , { 6 , 8 , 6 } , { 5 , 3 , 1 } } ; ( checkCentrosymmetricted ( n , m ) ? ( cout << " Yes " ) : ( cout << " No " ) ) ; return 0 ; }