Dimitar23308

okrujnosti2

Mar 12th, 2026
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     float x1, y1, x2, y2, x3, y3, px, py;
  6.  
  7.  
  8.     cout << "Vrah A: "; cin >> x1 >> y1;
  9.     cout << "Vrah B: "; cin >> x2 >> y2;
  10.     cout << "Vrah C: "; cin >> x3 >> y3;
  11.     cout << "Tochka P: "; cin >> px >> py;
  12.  
  13.     /
  14.     float checkABC = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
  15.  
  16.     if (checkABC == 0) {
  17.         cout << "Triagalnikat ne sashtestvuva!" << endl;
  18.         return 0;
  19.     }
  20.  
  21.     float d1 = (x2 - x1) * (py - y1) - (y2 - y1) * (px - x1); // Спрямо AB
  22.     float d2 = (x3 - x2) * (py - y2) - (y3 - y2) * (px - x2); // Спрямо BC
  23.     float d3 = (x1 - x3) * (py - y3) - (y1 - y3) * (px - x3); // Спрямо CA
  24.  
  25.    
  26.     bool all_left = (d1 >= 0 && d2 >= 0 && d3 >= 0);
  27.     bool all_right = (d1 <= 0 && d2 <= 0 && d3 <= 0);
  28.  
  29.     if (all_left || all_right) {
  30.         cout << "Tochkata e VATRE." << endl;
  31.     } else {
  32.         cout << "Tochkata e VAN." << endl;
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment