Point to lie on a circle. Help!

Please, would you help me with this program:

#include <iostream>
#include <cmath>
using namespace std;

void main()
{
cout << "x = ";
double x;
cin >> x;

cout << "y = ";
double y;
cin >> y;

bool c1 = ((((x + 1)*(x + 1) + (y - 1)*(y - 1)) <= 1) &&
(y <= (1/3*x + 1)) &&
(y >= (x + 1)) &&
(y >= 0));

if (c1)
cout << "true" << endl;
else
cout << "false" << endl;

}

http://imageshack.us/photo/my-images/38/cird.png/

The point don`t have to lie in (-2, 0.5), (-2, 1) and (0,1). :S
[code] "Please use code tags" [/code]
Integer division returns an integer
Also, don't know if you noticed this but for some reason in that picture, the negative y-axis is pointing up (don't know if that was a trick or not).

That would make it so this line:

y = x + 1 is actually this line y = -x - 1

and this line:

y = (1/3)x + 1 is actually this line y = -(1/3)x - 1

and of course the circle would be:

(x + 1)2 + (y + 1)2 = 1

and you would have to reverse the >= and the <= for the two lines (no need to check with respect to the line
y = 0)
Last edited on
Thank you! :)
Topic archived. No new replies allowed.