2017 Java Chapter 3 (Week 03)

From: 2017-09-01 00:00:00 To: 2017-10-11 23:59:59 Now: 2024-04-29 05:33:07 Status: Public

E - 기하: 사각형안의 점

Time Limit: 1s Memory Limit: 128MB

Submissions: 1404 Solved: 569
Description

중심이 (0, 0)이고 너비가 10, 높이가 5인 사각형이 주어져 있을때 입력받은 점 (x, y)가 해당 사각형 안에 포함되는지 안되는지 체크하는 프로그램을 작성하려고 합니다. 예를 들어, (2, 2)는 사각형 안에 포함되어 있으므로 in을 출력하고 (6, 4)는 사각형 밖에 있으므로 out을 출력하면 됩니다. 점이 사각형의 선분에 있을 경우에는 on을 출력합니다.

Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5. For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle, as shown in Figure 3.7b.

Input

* Line 1 : 점의 좌표 x y (x, y는 절대값이 1000을 넘지 않는 실수이며 공백으로 구분됨)

Output

* Line 1 : 점이 사각형 안에 있으면 in, 사각형의 변 위에 있으면 on, 사각형 밖에 있으면 out을 출력

Sample Input
6 4
Sample Output
out
Hint

A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to 10 / 2 and its vertical distance to (0, 0) is less than or equal to 5.0 / 2. Test your program to cover all cases.

Source

JAVA2015 PE3.23