Advertisement
informaticage

Esercizio stesso quadrante

Feb 10th, 2021
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. import math
  2.  
  3. class Punto:
  4.   x = 0
  5.   y = 0
  6.  
  7. punto_base = Punto()
  8. punto_base.x = int(input("X: "))
  9. punto_base.y = int(input("Y: "))
  10.  
  11. elenco_punti = []
  12. numero_punti = int(input("Numero punti: "))
  13.  
  14. for p in range(numero_punti):
  15.   punto_corrente = Punto()
  16.   punto_corrente.x = int(input("X: "))
  17.   punto_corrente.y = int(input("Y: "))
  18.  
  19.   elenco_punti.append(punto_corrente)
  20.  
  21. segno_x1 = math.copysign(1, punto_base.x)
  22. segno_y1 = math.copysign(1, punto_base.y)
  23.  
  24. stesso_quadrante = []
  25. for p in elenco_punti:
  26.   segno_x = math.copysign(1, p.x)
  27.   segno_y = math.copysign(1, p.y)
  28.  
  29.   if(segno_x == segno_x1 and segno_y == segno_y1):
  30.     stesso_quadrante.append(p)
  31.  
  32. for punto in stesso_quadrante:
  33.   print(punto.x, punto.y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement