#include
#include
#include
using namespace std;
class Point
{
public:
Point(float xx,float yy):x(xx) , y(yy){};
float x,y;
};
class Rectangle
{
public:
Point point1,point2;
Rectangle(float x1,float y1,float x2,float y2):point1(x1,y1),point2(x2,y2){};
bool IsIn(Point point)
{
return point.x > point1.x && point.x < point2.x && point.y < point1.y && point.y > point2.y;
}
};
class ACM476
{
public:
vectorrectangles;
vectorpoints;
};
int main(int argc, char *argv[])
{
ACM476 acm476;
while(true)
{
string input;
getline(cin,input);
istringstream ss;
ss.str(input);
string cmd;
float x1,y1,x2,y2;
ss >> cmd;
if(cmd=="*")
{
break;
}
switch(cmd[0])
{
case 'r':
ss >> x1;ss >> y1;ss >> x2;ss >> y2;
acm476.rectangles.push_back(Rectangle(x1,y1,x2,y2));
break;
}
}
while(true)
{
string input;
getline(cin,input);
istringstream ss;
ss.str(input);
float x,y;
ss >> x;
ss >> y;
if(x==9999.9f && y==9999.9f)
{
break;
}
acm476.points.push_back(Point(x,y));
}
for(vector::size_type ip =0;ip != acm476.points.size();++ip)
{
bool flag=false;
for(vector::size_type ir =0; ir != acm476.rectangles.size();++ir)
{
if(acm476.rectangles[ir].IsIn(acm476.points[ip]))
{
cout << "Point " << ip+1 << " is contained in figure " << ir+1 << endl;
flag=true;
}
}
if(!flag)
{
cout << "Point " << ip+1 <<" is not contained in any figure" << endl;
}
}
}
2008年10月30日 星期四
ACM476: Points in Figures: Rectangles
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言