题解 | #最小长方形#

最小长方形

https://www.nowcoder.com/practice/dc6a75a15d1948edafa6d63bc8fc2368

#include <cstdio>
using namespace std;
int main(){
    int x,y;
    while (scanf("%d%d",&x,&y)!=EOF) {
        if (x == 0 && y == 0) {
            break;
        }
        int x1, y1;
        int x2, y2, x3, y3;//
        x2 = x3 = x;
        y2 = y3 = y;
        while (scanf("%d%d", &x1, &y1) != EOF) {
            if (x1 == 0 && y1 == 0) {
                break;
            }
            if (x1 < x2) {
                x2 = x1;

            }
            if (y1 < y2) {
                y2 = y1;

            }
            if (x1 > x3) {
                x3 = x1;

            }
            if (y1 > y3) {
                y3 = y1;

            }
        }
        printf("%d %d %d %d\n", x2, y2, x3, y3);
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
球球别再泡了:坏,我单9要了14
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务