Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def intersection_check(k1, b1, k2, b2):
- if k1 != k2:
- x = (b2-b1) / (k1-k2)
- y = k1*x + b1
- return round(x, 3), round(y, 3)
- return None
- n = int(input("Введите кол-во прямых: "))
- all_lines = []
- print(f"Введите {n} прямых, задав 'y = kx + b' их коэффициенты - k, b (через пробел):")
- for _ in range(n):
- k, b = [float(x) for x in input().split()]
- all_lines.append((k, b))
- all_intersections = set()
- for checked_ind, checked_line in enumerate(all_lines):
- for ind, line in enumerate(all_lines):
- if ind != checked_ind:
- result = intersection_check(*checked_line, *line)
- if result is not None:
- all_intersections.add(result)
- """
- Для просмотра множества точек пересечения
- print(all_intersections)
- """
- print("Точек пересечения:", len(all_intersections))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement