覆盖所有点的最小矩形,输出左下和右上顶点坐标
#include<iostream>
using namespace std;
int x, y;
int Minx, Miny, Maxx, Maxy;
int main()
{
cin >> x >> y;
Minx = x; Miny = y; Maxx = x; Maxy = y;
while (x && y) {
cin >> x >> y;
if(x != 0 && y != 0){
Minx = x > Minx ? Minx : x;
Miny = y > Miny ? Miny : y;
Maxx = x < Maxx ? Maxx : x;
Maxy = y < Maxy ? Maxy : y;
}
}
cout << "(" << Minx << " , " << Miny << ")" << endl;
cout << "(" << Maxx << " , " << Maxy << ")" << endl;
return 0;
}