Java Reference
In-Depth Information
v 2 (x2, y2)
v 1 (x1, y1)
v 3 (x3, y3)
v 4 (x4, y4)
F IGURE 8.9
A 4-vertex polygon is defined by four vertices.
*8.34
( Geometry: rightmost lowest point ) In computational geometry, often you need
to find the rightmost lowest point in a set of points. Write the following method
that returns the rightmost lowest point in a set of points.
public static double []
getRightmostLowestPoint( double [][] points)
Write a test program that prompts the user to enter the coordinates of six points
and displays the rightmost lowest point. Here is a sample run:
Enter 6 points: 1.5 2.5 -3 4.5 5.6 -7 6.5 -7 8 1 10 2.5
The rightmost lowest point is (6.5, -7.0)
**8.35
( Largest block ) Given a square matrix with the elements 0 or 1, write a program
to find a maximum square submatrix whose elements are all 1s. Your program
should prompt the user to enter the number of rows in the matrix. The program
then displays the location of the first element in the maximum square submatrix
and the number of the rows in the submatrix. Here is a sample run:
Enter the number of rows in the matrix: 5
Enter the matrix row by row:
1 0 1 0 1
1 1 1 0 1
1 0 1 1 1
1 0 1 1 1
1 0 1 1 1
The maximum square submatrix is at (2, 2) with size 3
Your program should implement and use the following method to find the maxi-
mum square submatrix:
public static int [] findLargestBlock( int [][] m)
The return value is an array that consists of three values. The first two values are
the row and column indices for the first element in the submatrix, and the third
value is the number of the rows in the submatrix.
**8.36
( Latin square ) A Latin square is an n -by- n array filled with n different Latin let-
ters, each occurring exactly once in each row and once in each column. Write a
 
 
Search WWH ::




Custom Search