zoukankan      html  css  js  c++  java
  • HDU 1859

    #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);
        }
    }
  • 相关阅读:
    GitHub Interesting Collection
    使用 CSS3 Flexible Boxes 布局
    消失的属性
    浅谈 JavaScript 模块化编程
    为你的 Javascript 加点咖喱
    软件测试
    osi七层模型
    3_Hydra(爆破神器)
    2_NC(瑞士军刀)
    1_HTTP协议详解
  • 原文地址:https://www.cnblogs.com/mrethan/p/4630340.html
Copyright © 2011-2022 走看看