Does the point with the given coordinates fall into the shaded area?

alt text

Closed due to the fact that off-topic participants Timofei Bondarev , DeKaNszn , user31688, AntonioK , null 8 May '15 at 5:58 .

  • Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • @Rimp, According to the rules of the forum, questions should not be reduced to the decision or the completion of student assignments. Please clarify what you have done yourself and what did not work out. - DreamChild
  • First, not the fact that this is a girl. To consider that some professions are only for women, and some for men are moveton. Do you know that there are women astronauts? Why not be a male obstetrician? Secondly, I would be very interested to know why C ++ obstetricians. - VadimTukaev
  • four
    I vote for the closure of this issue as not relevant topic, because the work for the author - Timofei Bondarev

3 answers 3

It is possible to determine which side of the line is a point through a simple inequality.

alt text

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) 

alt text

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; } 
    • Mark corrected C ++ 11 to C ++. - Alex Krass

    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; }