2012-05-18 07:41:04Morris

[UVA] 11455 - Behold my quadrangle

 I. Behold My Quadrangle 

Context

Any square is a rectangle, any rectangle is a quadrangle, and any quadrangle is composed of four sides. But not all rectangles are squares, not all quadrangles are rectangles, and not all sets of four sides are quadrangles.

The Problem

We have the length of four sides. You have to determine if they can form a square. If not, determine if they can form a rectangle. If not, determine if they can form a quadrangle.

The Input

The first line of the input contains an integer indicating the number of test cases.

For each test case, there is a line with four positive integer numbers, between 0 and 230.

The Output

For each test case, the output should consist of a line with the text "square", "rectangle", "quadrangle" or "banana", if the sides of the corresponding case can form a square, a rectangle, a quadrangle or none, respectively.

Sample Input

4
10 8 7 6
9 1 9 1
29 29 29 29
5 12 30 7

Sample Output

quadrangle
rectangle
square
banana




#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
int t, e[4], i;
scanf("%d", &t);
while(t--) {
for(i = 0; i < 4; i++)
scanf("%d", e+i);
sort(e, e+4);
if(e[0] == e[3])
puts("square");
else if(e[0] == e[1] && e[2] == e[3])
puts("rectangle");
else if(e[3] <= e[0]+e[1]+e[2])
puts("quadrangle");
else
puts("banana");
}
return 0;
}
 

上一篇:[UVA] 11417 - GCD

下一篇:[UVA] 11494 - Queen