Advertisement
dream_4ild

9-И-2 ex.6

Dec 10th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.64 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sat Nov 21 17:27:04 2020
  4.  
  5. @author: Sergey
  6. """
  7.  
  8. import math
  9.  
  10.  
  11. x1_1, y1_1 = int(input()), int(input())
  12. x1_2, y1_2 = int(input()), int(input())
  13. x2_1, y2_1 = int(input()), int(input())
  14. x2_2, y2_2 = int(input()), int(input())
  15. data=[[x1_1, y1_1], [x1_2, y1_2], [x2_1, y2_1], [x2_2, y2_2]]
  16. data1=[]
  17. for i in range(3):
  18.     for j in range(i+1, 4):
  19.         a=data[i]
  20.         b=data[j]
  21.         x1=a[0]
  22.         y1=a[1]
  23.         x2=b[0]
  24.         y2=b[1]
  25.         s= math.sqrt(((x2-x1)**2) + ((y2-y1)**2))
  26.         data1.append(s)
  27. print(data1)
  28. c=max(data1)
  29. d=data1.index(c)
  30. data1.pop(d)
  31. data1.insert(d, 0)
  32. c1=max(data1)
  33. d1=data1.index(c1)
  34. data1.pop(d1)
  35. data1.insert(d1, 0)
  36. print('data1', data1)
  37. print(c)
  38. print(c1)
  39. if (c>data1[0]) and (c1>data1[0]) and (c>data1[1]) and (c1>data1[1]) and (c>data1[2]) (c1>data1[2]) and (c>data1[3]) and (c1>data1[3]) and (c>data1[4]) and (c1>data1[4]) and (c>data1[5]) and (c1>data1[5]):
  40.     if d==0:
  41.         x1_1, y1_1=data[0][0], data[0][1]
  42.         x1_2, y1_2=data[1][0], data[1][1]
  43.     elif d==1:
  44.         x1_1, y1_1=data[0][0], data[0][1]
  45.         x1_2, y1_2=data[2][0], data[2][1]
  46.     elif d==2:
  47.         x1_1, y1_1=data[0][0], data[0][1]
  48.         x1_2, y1_2=data[3][0], data[3][1]
  49.     elif d==3:
  50.         x1_1, y1_1=data[1][0], data[1][1]
  51.         x1_2, y1_2=data[2][0], data[2][1]
  52.     elif d==4:
  53.         x1_1, y1_1=data[1][0], data[1][1]
  54.         x1_2, y1_2=data[3][0], data[3][1]
  55.     elif d==5:
  56.         x1_1, y1_1=data[2][0], data[2][1]
  57.         x1_2, y1_2=data[3][0], data[3][1]
  58.     if d1==0:
  59.         x1_1, y1_1=data[0][0], data[0][1]
  60.         x1_2, y1_2=data[1][0], data[1][1]
  61.     elif d1==1:
  62.         x1_1, y1_1=data[0][0], data[0][1]
  63.         x1_2, y1_2=data[2][0], data[2][1]
  64.     elif d1==2:
  65.         x1_1, y1_1=data[0][0], data[0][1]
  66.         x1_2, y1_2=data[3][0], data[3][1]
  67.     elif d1==3:
  68.         x1_1, y1_1=data[1][0], data[1][1]
  69.         x1_2, y1_2=data[2][0], data[2][1]
  70.     elif d1==4:
  71.         x1_1, y1_1=data[1][0], data[1][1]
  72.         x1_2, y1_2=data[3][0], data[3][1]
  73.     elif d1==5:
  74.         x1_1, y1_1=data[2][0], data[2][1]
  75.         x1_2, y1_2=data[3][0], data[3][1]
  76.    
  77.    
  78.     A1 = y1_1 - y1_2
  79.     B1 = x1_2 - x1_1
  80.     C1 = x1_1*y1_2 - x1_2*y1_1
  81.     A2 = y2_1 - y2_2
  82.     B2 = x2_2 - x2_1
  83.     C2 = x2_1*y2_2 - x2_2*y2_1
  84.     if B1*A2 - B2*A1 != 0:
  85.         y = (C2*A1 - C1*A2) / (B1*A2 - B2*A1)
  86.         x = (-C1 - B1*y) / A1
  87.         if min(x1_1, x1_2) <= x <= max(x1_1, x1_2) and  \
  88.                                 min(y1_1, y1_2) <= y <= max(y1_1, y1_2):
  89.             print('Да')
  90.         else:
  91.             print('Нет')
  92. else:
  93.     print('Нет')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement