superman

聚精会神搞建设 一心一意谋发展
posts - 190, comments - 17, trackbacks - 0, articles - 0
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

ZOJ 1241 - Geometry Made Simple

Posted on 2008-05-08 10:03 superman 阅读(190) 评论(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 

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理