Does the point with the given coordinates fall into the shaded area?
![]()
It is possible to determine which side of the line is a point through a simple inequality.

You have four lines on the coordinate plane:
y = -x+5 y = -x+11 y = x+3 y = x-3 Putting down the necessary signs of inequality, you cut off the shape you are looking for.
(y > -x+5) and (y < -x+11) and (y < x+3) and (y > x-3) 
The final solution in C ++ is written in a couple of lines.
#include <iostream> using namespace std; int main() { double x, y; cin >> x >> y; if((y > -x+5) && (y < -x+11) && (y < x+3) && (y > x-3)) cout << "Попадает"; else cout << "Не попадает"; return 0; } I alone do not understand why there is C ++ 11? And in C ++ 03 or, scary to say, by a C goal, this task is already considered unsolvable? I believe that teaching computer science in C ++ (note that not teaching C ++ itself) is a crime worse than pedophilia. Pedophile, at least, not all of his students life breaks. Those who believe that computer science should be taught in C ++ are dangerous crazy people. Even to the teachers, still sticking to the children of Turbo Pascal and QBASIC, I am better. They are just harmless village fools.
#include <stdio.h> int higher(a, b, x, y) { return y > a * x + b; } int main(void) { int x, y; while (scanf("%d %d", &x, &y) == 2) { int inside = higher(-1, 5, x, y) && higher(1, -3, x, y) && !higher(1, 3, x, y) && !higher(-1, 11, x, y); printf("%s\n", inside ? "Yes!" : "No."); } return 0; } Carefully, govnokod!
#include <iostream> #include <math.h> using namespace std; int main() { double x=2,y=4; if (x<1 || x>7 || y<0) cout << "Нет\n"; x-=4;y-=4; if (x>0) x-=(3+x); if (y<(3+x) && y>(-3-x)) cout << "Да\n"; else cout << "Нет\n"; return 0; } Source: https://ru.stackoverflow.com/questions/410596/
All Articles