ACM (UVa) : 476


#include <stdio.h>

struct node {
    double x1;
    double y1;
    double x2;
    double y2;
} a [12];

int main ()
{
    char ch;
    int index = 0;

    while ( scanf ("%c", &ch) && ch != '*' ) {
        if ( ch != 'r' )
        continue;

        scanf ("%lf", &a [index].x1);
        scanf ("%lf", &a [index].y1);
        scanf ("%lf", &a [index].x2);
        scanf ("%lf", &a [index].y2);
        index++;
    }

    int numbering = 0;
    double x, y;
    while ( scanf ("%lf %lf", &x, &y) && x != 9999.9 && y != 9999.9 ) {

        bool flag = true;
        numbering++;
        for ( int i = 0; i < index; i++ ) {

            if ( x > a[i].x1 && x < a[i].x2 && y < a[i].y1 && y > a[i].y2 ) {
                printf ("Point %d is contained in figure %d\n", numbering, i + 1 );
                flag = false;
            }
        }

        if ( flag )
            printf ("Point %d is not contained in any figure\n", numbering);
    }

    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s