UVA 10522 Height to Area(知三角形三高求面积)

Posted carered

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA 10522 Height to Area(知三角形三高求面积)相关的知识,希望对你有一定的参考价值。

技术图片技术图片

 

 

思路:海伦公式,

AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 
 5     int n;
 6     scanf("%d",&n);
 7     double ha, hb, hc, a, b, c;
 8     while(~scanf("%lf %lf %lf",&ha,&hb,&hc))
 9     
10         a = 2.0 / ha;
11         b = 2.0 / hb ;
12         c = 2.0 / hc;
13         if(a <= 0.0 || b <= 0.0 || c <= 0.0 || a >= b+c || b >= a+c || c >= a+b )
14         
15             printf("These are invalid inputs!\\n");
16         
17         else 
18             double p = (a + b + c)*0.5;
19             double s = p * (p - a)*(p - b)*(p - c);
20             printf("%.3f\\n",sqrt(1.0 / s));
21         
22     
23     return 0;
24 

 

以上是关于UVA 10522 Height to Area(知三角形三高求面积)的主要内容,如果未能解决你的问题,请参考以下文章

UVA10589 Area计算几何

UVa 1641 ASCII Area (计算几何,水题)

函数式编程

UVA 11475 Extend to Palindrome KMP

UVA - 10273 Eat or Not to Eat?

11. 盛最多水的容器