题目1020:最小长方形(排除原点)
题目链接: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\n",minx,miny,maxx,maxy); init(); } } } /************************************************************** Problem: 1020 User: zpfbuaa Language: C++ Result: Accepted Time:0 ms Memory:1520 kb ****************************************************************/
作者: 伊甸一点
出处: http://www.cnblogs.com/zpfbuaa/
本文版权归作者伊甸一点所有,欢迎转载和商用(须保留此段声明),且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
原文链接 如有问题, 可邮件(zpflyfe@163.com)咨询.