Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- float x1, y1, x2, y2, x3, y3, px, py;
- cout << "Vrah A: "; cin >> x1 >> y1;
- cout << "Vrah B: "; cin >> x2 >> y2;
- cout << "Vrah C: "; cin >> x3 >> y3;
- cout << "Tochka P: "; cin >> px >> py;
- /
- float checkABC = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
- if (checkABC == 0) {
- cout << "Triagalnikat ne sashtestvuva!" << endl;
- return 0;
- }
- float d1 = (x2 - x1) * (py - y1) - (y2 - y1) * (px - x1); // Спрямо AB
- float d2 = (x3 - x2) * (py - y2) - (y3 - y2) * (px - x2); // Спрямо BC
- float d3 = (x1 - x3) * (py - y3) - (y1 - y3) * (px - x3); // Спрямо CA
- bool all_left = (d1 >= 0 && d2 >= 0 && d3 >= 0);
- bool all_right = (d1 <= 0 && d2 <= 0 && d3 <= 0);
- if (all_left || all_right) {
- cout << "Tochkata e VATRE." << endl;
- } else {
- cout << "Tochkata e VAN." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment