Skip to content

Commit dc9eb6e

Browse files
Pythagorean triplets
Takes input from the user and check if a given set of numbers is a valid pythagorean triplet.
1 parent 7f1df0c commit dc9eb6e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Diff for: Pythagorean Triplets

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import java.util.*;
2+
3+
public class Main {
4+
5+
public static void main(String[] args) {
6+
Scanner scn = new Scanner(System.in);
7+
int a = scn.nextInt();
8+
int b = scn.nextInt();
9+
int c = scn.nextInt();
10+
11+
int max = a;
12+
if(b >= max)
13+
max = b;
14+
15+
if(c >= max)
16+
max = c;
17+
18+
if(max == a){
19+
System.out.println((b * b + c * c) == (a * a));
20+
} else if(max == b){
21+
System.out.println((a * a + c * c) == (b * b));
22+
} else {
23+
System.out.println((a * a + b * b) == (c * c));
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)