UVA-3.10-盒子-1587

#include 
#include 
#include 
struct A
{
    int x;
    int y;
};
int main()
{
    struct A num[8];
    //memset("num,0,sizeof(num)");
    //freopen("D:\\output.txt", "w", stdout);
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        if(a>b)
        {
            num[1].y=a;
            num[1].x=b;
        }
        else
        {
            num[1].x=a;
            num[1].y=b;
        }
        int i,j,k,m,n;
        n=6;
        for(i=2; i<=6; i++)
        {
            scanf("%d%d",&a,&b);
            if(a>b)
            {
                num[i].y=a;
                num[i].x=b;
            }
            else
            {
                num[i].x=a;
                num[i].y=b;
            }
        }
        struct A t;
        for(i=1; i<=n; i++)
        {
            for(j=1; j<=n-i; j++)
            {
                if(num[j].x>num[j+1].x)
                {
                    t=num[j];
                    num[j]=num[j+1];
                    num[j+1]=t;
                }
                if(num[j].x==num[j+1].x)
                {
                    if(num[j].y>num[j+1].y)
                    {
                        t=num[j];
                        num[j]=num[j+1];
                        num[j+1]=t;
                    }
                }
            }
        }
        int count=0;
        struct A box[4];
        //printf("11");
        //printf("n=%d\n",n);
        i=1;
        for(i=1; i<=n; i++)
        {
            if(num[i].x==num[i+1].x&&num[i].y==num[i+1].y)
            {
                count=count+1;
                box[count].x=num[i].x;
                box[count].y=num[i].y;
                //printf("**%d\n",count);
            }
            i++;
            //printf("i=%d\n",i);
        }
        //printf("count=%d\n",count);
        if(count!=3)
        {
            printf("IMPOSSIBLE\n");
            continue;
        }
        //printf("\n");
        else
        {   //排序之后会符合下列规律
            if(box[1].x!=box[2].x)
                printf("IMPOSSIBLE\n");
            else
              if(box[1].y!=box[3].x)
                printf("IMPOSSIBLE\n");
            else
              if(box[2].y!=box[3].y)
                printf("IMPOSSIBLE\n");
            else
              printf("POSSIBLE\n");



        }
    }
    return 0;
}


你可能感兴趣的:(UVA-3.10-盒子-1587)