// UVa 476 - Points in Figures: Rectangles #include <iostream> #include <stdio.h> using namespace std; struct rect { double x1, x2, y1, y2; }; int main() { char ch; cin >> ch; int n = 0; rect r[11]; while (ch == 'r') { double x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; n++; r[n].x1 = min(x1, x2); r[n].x2 = max(x1, x2); r[n].y1 = min(y1, y2); r[n].y2 = max(y1, y2); cin >> ch; } double x, y; cin >> x >> y; int j = 0; while (x != 9999.9 || y != 9999.9) { j++; bool found = false; for (int i = 1; i <= n; i++) { if (x > r[i].x1 && x < r[i].x2 && y > r[i].y1 && y < r[i].y2) { printf("Point %d is contained in figure %d\n", j, i); found = true; } } if (!found) printf("Point %d is not contained in any figure\n", j); cin >> x >> y; } return 0; }
Monday, June 8, 2015
UVa 476 - Points in Figures: Rectangles
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment