-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
executable file
·55 lines (47 loc) · 1.13 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.io.*;
import java.util.*;
class Main{
public static void main(String [] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
StringTokenizer st;
String line;
double a, b, c;
int t = 1;
while(!(line = br.readLine()).equals("0 0 0")){
st = new StringTokenizer(line);
a = Double.parseDouble(st.nextToken());
b = Double.parseDouble(st.nextToken());
c = Double.parseDouble(st.nextToken());
if(a < 0){
a = c * c - b * b;
out.println("Triangle #"+t);
if(a <= 0)
out.println("Impossible.");
else{
a = Math.sqrt(a);
out.printf("a = %.3f\n", a);
}
}
else if(b <= 0){
b = c * c - a * a;
out.println("Triangle #"+t);
if(b <= 0)
out.println("Impossible.");
else{
b = Math.sqrt(b);
out.printf("b = %.3f\n", b);
}
}
else if(c < 0){
c = a * a + b * b;
c = Math.sqrt(c);
out.println("Triangle #"+t);
out.printf("c = %.3f\n", c);
}
out.println();
t++;
}
out.flush();
}
}