题目链接:http://ac.jobdu.com/problem.php?pid=1020
详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus
参考代码:
// // 1020 最小长方形.cpp // Jobdu // // Created by PengFei_Zheng on 29/04/2017. // Copyright © 2017 PengFei_Zheng. All rights reserved. // #include <stdio.h> #include <iostream> #include <algorithm> #include <string.h> #include <cstring> #include <cmath> using namespace std; int x, y; int minx,miny; int maxx,maxy; bool flag; void init(){ flag = true; minx = miny = 232; maxx = maxy = -232; } int main(){ // freopen("/Users/pengfei_zheng/Desktop/input.txt", "r", stdin); init(); while(scanf("%d%d",&x,&y)!=EOF){ if(x!=0 || y!=0){ minx = min(minx,x); miny = min(miny,y); maxx = max(maxx,x); maxy = max(maxy,y); flag = false; } if(flag && x==0 && y==0){ break; } if(x==0 && y==0){ printf("%d %d %d %d ",minx,miny,maxx,maxy); init(); } } } /************************************************************** Problem: 1020 User: zpfbuaa Language: C++ Result: Accepted Time:0 ms Memory:1520 kb ****************************************************************/