24h購物| | PChome| 登入
2012-05-18 07:41:04| 人氣1,073| 回應0 | 上一篇 | 下一篇

[UVA] 11455 - Behold my quadrangle

推薦 0 收藏 0 轉貼0 訂閱站台

 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;
}
 

台長: Morris
人氣(1,073) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA] 11494 - Queen
此分類上一篇:[UVA] 11417 - GCD

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文