2012年4月3日 星期二

UVa 476

#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    char word;
    int endPtr = 0, counter = 0;
    
    double ptr[11][5];
    for (int i = 0; i < 11; i++)
        for (int j = 0; j < 5; j++)
            ptr[i][j] = 0.0;
        
    while ( true )
    {
        cin >> word;
        if (word == '*')
        {
            endPtr = counter;
            break;
        }

        cin >> ptr[counter][1] >> ptr[counter][2] >> ptr[counter][3] >> ptr[counter][4];
        counter++;
    }

    double x = 0.0, y = 0.0;
    int dot = 1;
    while (cin >> x >> y && (x != 9999.9 && y != 9999.9))
    {
        bool have = true;
        for (int i = 0; i <= endPtr; i++)
        {
            if ( (x > ptr[i][1] && x < ptr[i][3] && (y > ptr[i][4] && y < ptr[i][2])))
            {
                cout << "Point " << dot << " is contained in figure " << i << endl;
                have = false;
            }
        }

        if ( have )
            cout << "Point " << dot << " is not contained in any figure" << endl;

        dot++;
    }


    return 0;
}

沒有留言:

張貼留言