text: Finding GCD of each row and column and replacing with each element with maximum of GCD of row or column .
code: void replacematrix ( int mat [ R ] [ C ] , int n , int m ) { int rgcd [ R ] = { 0 } , cgcd [ C ] = { 0 } ;