#if 1 /********************************************* This program reads in points from a file points.txt and writes out the lower left and upper right endpoints of a rectangle containing all the points read in. **********************************************/ #include #include #include using namespace std; struct point { double x,y; }; int main() { // Open input file and read header information ifstream IN("points.txt"); int N; string s; IN >> N >> s; // Read points into array int i; point *A = new point[N]; // use this! for (i=0; i < N; i++) { IN >> A[i].x >> A[i].y; } // Find lower left (min x and min y) and upper right corners point ptLL, ptUR; // use this! ptLL = ptUR = A[0]; // default for (i=0; i ptUR.x) { ptUR.x = A[i].x; } if (A[i].y > ptUR.y) { ptUR.y = A[i].y; } } // Print out lower left and upper right corner of // bounding rectangle cout << "Points are contained in rectangle with\n" << "lower left corner (" << ptLL.x << ',' << ptLL.y << ") and\nupper right corner (" << ptUR.x << ',' << ptUR.y << ')' << endl; return 0; } #endif