Розбір
Let be the sides of a triangle. A triangle is a right triangle if one of the following equalities holds:
(the hypotenuse is the side )
(the hypotenuse is the side )
(the hypotenuse is the side )
Algorithm realization
Read the input data until the end of the file.
while(scanf("%d %d %d",&a,&b,&c)) {
If there are three zeros, terminate the program.
if (a + b + c == 0) break;
Check if the triangle is a right triangle. Depending on the result, print the answer.
if ((a * a + b * b == c * c) || (a * a + c * c == b * b) || (b * b + c * c == a * a)) puts("right"); else puts("wrong"); }
Java realization
import java.util.*; public class Main { public static void main(String[] args) { Scanner con = new Scanner(System.in); while(con.hasNextInt()) { int a = con.nextInt(); int b = con.nextInt(); int c = con.nextInt(); if (a + b + c == 0) break; if ((a * a + b * b == c * c) || (a * a + c * c == b * b) || (b * b + c * c == a * a)) System.out.println("right"); else System.out.println("wrong"); } con.close(); } }
Python realization
Read the input data until the end of the file.
while True: a, b, c = map(int, input().split())
If there are three zeros, terminate the program.
if a + b + c == 0: break
Check if the triangle is a right triangle. Depending on the result, print the answer.
if (a * a + b * b == c * c) or (a * a + c * c == b * b) or (b * b + c * c == a * a): print("right"); else: print("wrong")