Print rectangular pattern with given center | Function to print the matrix filled with rectangle pattern having center coordinates are c1 , c2 ; Iterate in the range [ 0 , n - 1 ] ; Iterate in the range [ 0 , n - 1 ] ; Given Input ; Function Call
function printRectPattern ( c1 , c2 , n ) { for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { document . write ( Math . max ( Math . abs ( c1 - i ) , Math . abs ( c2 - j ) ) + " " ) ; } document . write ( " " ) ; } } let c1 = 2 ; let c2 = 2 ; let n = 5 ; printRectPattern ( c1 , c2 , n ) ;