Maximum distinct lines passing through a single point | function to find maximum lines which passes through a single point ; Driver Code
< ? php function maxLines ( $ n , $ x1 , $ y1 , $ x2 , $ y2 ) { $ s = array ( ) ; $ slope ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { if ( $ x1 [ $ i ] == $ x2 [ $ i ] ) $ slope = PHP_INT_MAX ; else $ slope = ( $ y2 [ $ i ] - $ y1 [ $ i ] ) * 1.0 / ( $ x2 [ $ i ] - $ x1 [ $ i ] ) * 1.0 ; array_push ( $ s , $ slope ) ; } return count ( $ s ) ; } $ n = 2 ; $ x1 = array ( 1 , 2 ) ; $ y1 = array ( 1 , 2 ) ; $ x2 = array ( 2 , 4 ) ; $ y2 = array ( 2 , 10 ) ; echo maxLines ( $ n , $ x1 , $ y1 , $ x2 , $ y2 ) ; ? >