UVA1587 UVALive3214 POJ2160 Box

Source: Internet
Author: User

Regionals 2004 >> Europe-northeastern

Problem Link: UVA1587 UVALive3214 POJ2160 Box.

Question Summary: Give six sets of integers, ask whether can constitute hexahedral.

This problem in C language does not have the technical content, perhaps in C + + to write better.


The C language Program of AC is as follows:

/* UVA1587 UVALive3214 POJ2160 Box */#include <stdio.h> #define MAXN 6struct {int W, h; int count;}        A[maxn];int acount;void Swap (int n) {if (A[n].w > a[n].h) {int temp = A[N].W;        A[N].W = a[n].h;    A[n].h = temp;    }}int Checkok () {if (A[0].W = = A[1].W && a[0].h = a[2].w && a[1].h = a[2].h) return 1;    else if (A[0].W = = A[1].W && a[0].h = = a[2].h && a[1].h = A[2].W) return 1;    else if (A[0].W = = A[1].h && a[0].h = = A[2].W && A[1].W = a[2].h) return 1;    else if (A[0].W = = A[1].h && a[0].h = = a[2].h && A[1].W = A[2].W) return 1;    else if (a[0].h = = A[1].W && A[0].W = = A[2].W && a[1].h = a[2].h) return 1;    else if (a[0].h = = A[1].W && A[0].W = = a[2].h && a[1].h = A[2].W) return 1;    else if (a[0].h = = A[1].h && A[0].W = = A[2].W && A[1].W = a[2].h) return 1; else if (a[0].h = = A[1].h && A[0].W = = a[2].h && A[1].W = a[2].w] return 1; else return 0;}    int main (void) {int I, J;        while (scanf ("%d%d", &AMP;A[0].W, &a[0].h)! = EOF) {a[0].count = 1;        Swap (0);        acount = 1;            for (I=1; i<maxn; i++) {scanf ("%d%d", &AMP;A[ACOUNT].W, &a[acount].h);            A[acount].count = 1;            Swap (acount); /* To repeat */for (j=0; j<acount; j + +) if (A[J].W = = A[ACOUNT].W && a[j].h = a[acount].h &                    amp;& A[j].count! = 2) {a[j].count++;                    acount--;                Break        } acount++;        } if (acount! = 3) printf ("impossible\n");        else if (Checkok ()) printf ("possible\n");    else printf ("impossible\n"); } return 0;}


UVA1587 UVALive3214 POJ2160 Box

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.