#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <stdio.h> using namespace std; typedef struct point { int x; int y; }PointType; int main() { vector<PointType> vecPoint; //存取全部输入用例 vector<int> vec_x, vec_y; PointType Point; while(1) //读取测试用例 { scanf("%d %d",&Point.x, &Point.y); if(Point.x == 0 && Point.y == 0 && vecPoint.size() > 0 ) //如果输入点为(0,0) 样例输入结束 { //查找最小长方形 //其实就是查找最小的(Xmin,Ymin) (Xmax,Ymax) for( size_t it = 0; it != vecPoint.size(); ++it) { vec_x.push_back(vecPoint[it].x); vec_y.push_back(vecPoint[it].y); } //对vec_x vec_y进行排序 sort(vec_x.begin(), vec_x.end()); sort(vec_y.begin(), vec_y.end()); cout << vec_x[0] <<" "<< vec_y[0] <<" "<<vec_x[vec_x.size() - 1] << " " << vec_y[vec_y.size() - 1] << endl; vecPoint.clear(); vec_x.clear(); vec_y.clear(); } else if( Point.x == 0 && Point.y == 0 && vecPoint.size() == 0) //存取测试用例 { break; } else if(Point.x != 0 || Point.y != 0) vecPoint.push_back(Point); } }