Demo entry 6838860

cd

   

Submitted by anonymous on Jun 12, 2019 at 02:57
Language: C++. Code size: 1.2 kB.

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include <iostream.h>
#include <math.h>
#include <tchar.h>
//---------------------------------------------------------------------------

#pragma argsused
int _tmain(void)
{

	double x, y;
	bool r1,r2,r3,r4;
	bool c1, c2, c3;
	char comma;

	cout << "Introduzca coordenadas x,y: " << endl;
	cin >> x;
	cin >> comma;
	cin >> y;
	cout << endl;

	// Region 1
	c1 =  y <= (-x + 2);
	c2 =  1 >= (pow(x - 1, 2) + pow(y - 1, 2));
	r1 = c1 && c2;

	// Region 2
	c1 = (y >= (x + 2)) && (1 >= (pow(x + 1, 2) + pow(y - 1, 2)));
	c2 = (y >= (x + 2)) && (1 >= (pow(x + 1, 2) + pow(y - 1, 2)));
	c3 = (x <= 0) && (y >= 0);
	r2 = (c1 || c2) && c3;

	// Region 3
	r3 = (y <= (-x - 2)) && (1 >= (pow(x + 1, 2) + pow(y + 1, 2)));

	// Region 4
	r4= (y >= (x - 2)) && (1 >= (pow(x - 1, 2) + pow(y + 1, 2)));

//	if (r1 || r2 || r3 || r4) {
	if (r1 || r2 || r3 || r4 ) {
		cout << "Puntro dentro de la region" << endl;
	}else
	{
		cout << "Puntro fuera de la region" << endl;
	}
	system("PAUSE");
	return 0;
}
//---------------------------------------------------------------------------

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).