UVA 11455 (Behold My Quadrangle) Solution
Solve in C:
#include<stdio.h>
#include<math.h>
int main ()
{
long long int n,a,b,c,d,i;
while(scanf("%lld",&n)!=EOF)
{
for(i=1; i<=n; i++)
{
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(((a==b&&b==c)&&(c==d&&d==a))&&(c==a&&b==d))
printf("square\n");
else if((a==c&&b==d)||(b==c&&a==d)||(a==b&&c==d)||(c==d&&d==a))
printf("rectangle\n");
else if(((a+b+c>d)&&(b+c+d>a))&&((a+c+d>b)&&(a+b+d>c)))
printf("quadrangle\n");
else
printf("banana\n");
}
}
}
#include<stdio.h>
#include<math.h>
int main ()
{
long long int n,a,b,c,d,i;
while(scanf("%lld",&n)!=EOF)
{
for(i=1; i<=n; i++)
{
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(((a==b&&b==c)&&(c==d&&d==a))&&(c==a&&b==d))
printf("square\n");
else if((a==c&&b==d)||(b==c&&a==d)||(a==b&&c==d)||(c==d&&d==a))
printf("rectangle\n");
else if(((a+b+c>d)&&(b+c+d>a))&&((a+c+d>b)&&(a+b+d>c)))
printf("quadrangle\n");
else
printf("banana\n");
}
}
}
No comments