思路:海伦公式,
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 }
原文地址:https://www.cnblogs.com/Carered/p/11406630.html
时间: 2024-10-10 21:48:23