Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Where is the code. What I missing? I receive 92% from 100 with both variants.
- Write a program to check if a point {x, y} is on some of the sides of a rectangle {x1, y1} β {x2, y2}.
- Input
- The input comes from the console and it consists of 6 rows, introduced from the user:
- real numbers x1, y1, x2, y2, x and y (it will be always true that x1 < x2 and y1 < y2).
- Output
- If the point lies on one of the rectangle's sides:
- Print "Border"
- If the point does NOT lie on a side:
- Print "Inside / Outside"
- Example
- Input Output Input Output
- 2 Inside / Outside 2 Border
- -3 -3
- 12 12
- 3 3
- 8 12
- -1 -1
- * Hint: use one or more conditional if statements with logical operations.
- A point {x, y} lies on aside of a rectangle {x1, y1} β {x2, y2}, if one of the specified conditions is fulfilled:
- x equals x1 or x2 and at the same time y is between y1 and y2
- y equals y1 or y2 and at the same time x is between x1 and x2
- You can check the conditions above using one more complicated if-else construction or using
- few more simple conditional statements or nested if-else statements.
- '''
- x1=float(input())
- y1=float(input())
- x2=float(input())
- y2=float(input())
- x=float(input())
- y=float(input())
- if x1 == x and y1 < y < y2:
- print("Border")
- elif x2 == x and y1 < y < y2:
- print("Border")
- elif y1 == y and x1 < x < x2 :
- print("Border")
- elif y2 == y and x1 < x < x2:
- print("Border")
- else:
- print ("Inside / Outside")
- '''
- x1=float(input())
- y1=float(input())
- x2=float(input())
- y2=float(input())
- x=float(input())
- y=float(input())
- if x1 == x :
- if y1 < y < y2:
- print("Border")
- else:
- print ("Inside / Outside")
- elif x2 == x :
- if y1 < y < y2:
- print("Border")
- else:
- print ("Inside / Outside")
- elif y1 == y :
- if x1 < x < x2:
- print("Border")
- else:
- print ("Inside / Outside")
- elif y2 == y :
- if x1 < x < x2:
- print("Border")
- else:
- print ("Inside / Outside")
- else:
- print("Inside / Outside")
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement