X-man

导航

hdu1895(最小长方形)

#include<stdio.h>
int main()
{
    int x1,y1;
    int x,y;
    int xm,ym,xa,ya;
    while(scanf("%d %d",&x1,&y1)!=EOF&&(x1!=0||y1!=0))
    {
        xm=x1;//最小的x
        xa=x1;//最大的y
        ym=y1;
        ya=y1;
        while(scanf("%d %d",&x,&y)!=EOF&&(x!=0||y!=0))
        {
            if(x<xm)xm=x;
            if(x>xa)xa=x;
            if(y<ym)ym=y;
            if(y>ya)ya=y;
        }
        printf("%d %d %d %d\n",xm,ym,xa,ya);
    }
}

        x和y都为0时,为结束符!

posted on 2013-04-13 19:53  雨钝风轻  阅读(200)  评论(0编辑  收藏  举报