Coordinates of rectangle with given points lie inside | function to print coordinate of smallest rectangle ; find Xmax and Xmin ; find Ymax and Ymin ; print all four coordinates ; Driver Code
< ? php function printRect ( $ X , $ Y , $ n ) { $ Xmax = max ( $ X ) ; $ Xmin = min ( $ X ) ; $ Ymax = max ( $ Y ) ; $ Ymin = min ( $ Y ) ; echo " { " , $ Xmin , " , ▁ " , $ Ymin , " } " , " STRNEWLINE " ; echo " { " , $ Xmin , " , ▁ " , $ Ymax , " } " , " STRNEWLINE " ; echo " { " , $ Xmax , " , ▁ " , $ Ymax , " } " , " STRNEWLINE " ; echo " { " , $ Xmax , " , ▁ " , $ Ymin , " } " ; } $ X = array ( 4 , 3 , 6 , 1 , -1 , 12 ) ; $ Y = array ( 4 , 1 , 10 , 3 , 7 , -1 ) ; $ n = count ( $ X ) ; printRect ( $ X , $ Y , $ n ) ; ? >