Posted on 2008-05-08 10:03
superman 阅读(203)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1241 C++ 00:00.00 844K */
2 #include <math.h>
3 #include <iostream>
4
5 using namespace std;
6
7 int main()
8 {
9 cout.setf(ios_base::showpoint);
10 cout.setf(ios_base::fixed);
11 cout.precision(3);
12
13 int a, b, c, n = 0;
14 while(cin >> a >> b >> c)
15 {
16 if(a == 0 && b == 0 && c == 0)
17 break;
18 n++;
19 cout << "Triangle #" << n << endl;
20 if(a == -1)
21 {
22 if(b >= c)
23 cout << "Impossible." << endl;
24 else
25 cout << "a = " << pow(c * c - b * b, 0.5) << endl;
26 }
27 if(b == -1)
28 {
29 if(a >= c)
30 cout << "Impossible." << endl;
31 else
32 cout << "b = " << pow(c * c - a * a, 0.5) << endl;
33 }
34 if(c == -1)
35 cout << "c = " << pow(a * a + b * b, 0.5) << endl;
36 cout << endl;
37 }
38
39 return 0;
40 }
41