476 - Points in Figures: Rectangles

476 - Points in Figures: Rectangles



#include<bits/stdc++.h>
using namespace std;
struct recPoint{   
 double x1,y1,x2,y2;};
int main(){
    char c;
    recPoint r[11];
    int i=0;
    while(true) 
   {
        cin>>c;
        if(c=='*') break;
        if(c=='r')                                  cin>>r[i].x1>>r[i].y1>>r[i].x2>>r[i].y2;        
i++;

    }    
double a,b;   
 int w=1,v;   
 bool flag=false;    
while(true)    { 
       cin>>a>>b;        flag=false;        v=-1;
        if(a==9999.9&&b==9999.9) break;        for(int j=0;j<i;j++)        {
            if(r[j].x1<a&&r[j].x2>a&&r[j].y1>b&&r[j].y2<b)            {

                flag=true;
                printf("Point %d is contained in figure %d\n",w,j+1);

            }        }
        if(!flag)
            printf("Point %d is not contained in any figure\n",w);        w++;    }
return 0;}


SHARE

Amit Ghosh

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment