fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Punkt {
  5. double x;
  6. double y;
  7. };
  8.  
  9. void czytaj_punkt(Punkt &p, double x, double y) {
  10. p.x = x;
  11. p.y = y;
  12. }
  13.  
  14. double det(Punkt A, Punkt B, Punkt P) {
  15. return (B.x - A.x) * (P.y - A.y) - (B.y - A.y) * (P.x - A.x);
  16. }
  17.  
  18. bool punkt_po_stronie(Punkt A, Punkt B, Punkt P) {
  19. return det(A,B,P) < 0;
  20. }
  21.  
  22. int main() {
  23. Punkt A, B, P;
  24.  
  25. czytaj_punkt(A, 1, 1);
  26. czytaj_punkt(B, 3, 3);
  27. czytaj_punkt(P, 0, 1);
  28.  
  29. if(det(A,B,P) < 0)
  30. cout << "Punkt P lezy po lewej stronie";
  31. else
  32. cout << "Punkt P lezy po prawej stronie";
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Punkt P lezy po prawej stronie