UVa 11854 - Egypt

11854 - Egypt

 * http://uva.onlinejudge.org/external/118/11854.html

Summary
Determining if a triangle is a right triangle or not, lengths of the 3 sides of the triangle are given. Just implementation of Pythagorean theorem.

Explanation
Pythagorean theorem states that the square of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides. The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the "Pythagorean equation": a^2 + b^2 = c^2, where c represents the length of the hypotenuse and a and b the lengths of the triangle's other two sides.

So, here a, b, c are given, just check if the value of a, b, c satisfies the Pythagorean theorem or not.

Implementations
The input values may not be in sorted order, so, any of the three values can be the length of the hypotenuse. So, check for all the three values.

Optimizations
Not necessary to use library function to calculate the square of any value, just simply multiply the value by itself.

Input
6 8 10 25 52 60 5 12 13 0 0 0

Output
right wrong right

Solutions

 * C++ : http://github.com/shahed-shd/Online-Judge-Solutions/blob/master/UVa-Online-Judge/11854%20-%20Egypt.cpp