Advertisement
viligen

longer_line

Oct 11th, 2021
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. import math
  2.  
  3.  
  4. def longer_line(x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4):
  5.  
  6.     line1 = math.sqrt((math.pow((x_1 - x_2), 2) + math.pow((y_1 - y_2), 2)))
  7.     line2 = math.sqrt((math.pow((x_3 - x_4), 2) + math.pow((y_3 - y_4), 2)))
  8.  
  9.     if line1 >= line2 and (pow(x_1, 2) + pow(y_1, 2)) <= (pow(x_2, 2) + pow(y_2, 2)):
  10.         print(f"({math.floor(x_1)}, {math.floor(y_1)})({math.floor(x_2)}, {math.floor(y_2)})")
  11.     elif line1 >= line2:
  12.         print(f"({math.floor(x_2)}, {math.floor(y_2)})({math.floor(x_1)}, {math.floor(y_1)})")
  13.  
  14.     elif line1 < line2 and (pow(x_3, 2) + pow(y_3, 2)) <= (pow(x_4, 2) + pow(y_4, 2)):
  15.         print(f"({math.floor(x_3)}, {math.floor(y_3)})({math.floor(x_4)}, {math.floor(y_4)})")
  16.     else:
  17.         print(f"({math.floor(x_4)}, {math.floor(y_4)})({math.floor(x_3)}, {math.floor(y_3)})")
  18.  
  19.  
  20. x1 = float(input())
  21. y1 = float(input())
  22. x2 = float(input())
  23. y2 = float(input())
  24. x3 = float(input())
  25. y3 = float(input())
  26. x4 = float(input())
  27. y4 = float(input())
  28.  
  29. longer_line(x1, y1, x2, y2, x3, y3, x4, y4)
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement