第八章第三十四题(几何:最右下角的点)(Geometry: bottom right point)
-
*8.34(几何:最右下角的点)在计算几何中经常需要从一个点集中找到最右下角的点。编写以下方法,从一个点的集合中返回最右下角的点。
public static double[] getRightmostLowestPoint(double[][] points)
编写一个测试程序,提示用户输入6个点的坐标,然后显示最右下角的点。下面是一个运行示例。
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.34(Geometry: bottom right point)In computational geometry, it is often necessary to find the lowest right corner point from a point set. Write the following method to return the bottom right point from a collection of points.
public static double[] getRightmostLowestPoint(double[][] points)
Write a test program, prompt the user to enter the coordinates of six points, and then display the point at the bottom right corner. Here is a running example.
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) -
参考代码:
package chapter08; import java.util.Scanner; public class Code_34 { public static void main(String args[]){ Scanner cin = new Scanner(System.in); System.out.print("Enter 6 points:"); double[][] points = new double[6][2]; for