Help needed considering formula.

Hello.
I need help figuring out the formula for an exercise.
I need to set up a program, that would check if the point N (x and y points inserted by the user) would be in the striped part.
Here is the picture with the striped part - http://gyazo.com/832bf38115362969f33bfa2580410e80.png?1348593265

So far i have written everything, except for the formula itself, and i can't come up with any solution.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream.h>
#include <conio.h>
void main(){
	int x,y;
   cout<<"Ievadi punkta N x koordinatu: ";
   cin>>x;
   cout<<"Ievadi punkta N y koordinatu: ";
   cin>>y;
   if(){
   	cout<<"Punkts N pieder iesvitrotajai dalai.";
   }else{
   	cout<<"Punkts N nepieder iesvitrotajai dalai.";
   }
   getch();
}


Thanks in advance.
Well, the word "formula" may be misleading. You don't need to do it all in a single line. You could create a function which takes the x and y values as input and returns a boolean (true or false) value.

Then think about the problem in easy stages, one section at a time. For example, if y is less than a certain figure, the point is definitely outside. If y is greater than a certain value, the point is definitely inside. That then reduces the remaining part of the problem to one section of the diagram.

By the way, you have specified above that x and y are integers. If this is really the requirement, the answer becomes trivial, because certain parts of the diagram would be always off limits.

But I think it more likely (check the question) that floating point or double values would be necessary.
Thanks, i got it sorted out.
Topic archived. No new replies allowed.