Determine the triangle type and determine the triangle
Description |
Three edges of a triangle: a, B, and c. Determine the triangle type. |
About Input |
The first line is the number of test data n (n <1000), followed by each row of n has three positive integers (the value cannot exceed 20000), respectively, the side length of the three sides of the triangle. |
About output |
For each group of input, determine the triangle type. The output "dyzj" indicates the isosceles right triangle, and "ptzj" indicates the normal right triangle. The db equilateral triangle, dyrj indicates the isosceles acute triangle, and ptrj indicates the normal acute triangle; "dydj" and "ptdj" are common blunt Triangles. "bssjx" cannot form triangles. |
Example Input |
23 4 530 30 30 |
Example output |
ptzjdb |
Prompt |
The sum of the two shorter sides is greater than the square of the longest side. This triangle is an acute triangle; The sum of the squares of the two shorter edges is less than the square of the longest edges. This triangle is an acute triangle; The sum of the squares of the two shorter edges is equal to the square of the longest edges. This triangle is a right triangle. |
|
# Include <stdio. h> # include <stdlib. h> int less (const void * p, const void * q) {int a = * (const int *) p; int B = * (const int *) q; return a-B;} int main () {int n = 0; scanf ("% d", & n); while (n --) {int a [3]; const char * p = 0; scanf ("% d", & a [0], & a [1], & a [2]); qsort (a, 3, sizeof (int), less); if (a [0] + a [1] <= a [2]) /* cannot form a triangle */{p = "bssjx ";} else {int delta = a [0] * a [0] + a [1] * a [1]-a [2] * a [2]; if (delta> 0)/* acute triangle */{if (a [0] = a [2]) p = "db "; else if (a [0] = a [1] | a [1] = a [2]) p = "dyrj"; elsep = "ptrj ";} else if (delta = 0)/* right triangle */{p = "ptzj";/* think about why you don't need to judge the right triangle at the same waist? */} Else/* if (delta <0) * // * blunt triangle */{if (a [0] = a [1]) p = "dydj "; elsep = "ptdj" ;}} printf ("% s" "\ n", p);} return 0 ;} |