Solution:
radius of an inscribed circle of a triangle
r = (2 * area of triangle) /perimeter of triangle;
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 |
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { int t; double B,H,R,d,a,b,r,h,c,l; double x; cin>>t; while(t--) { cin>>B>>H; l=H; h=H; a=(B/2)*(B/2); c=H*H; d=0; r=(B*H)/(B+2*sqrt(a+c)); R=r; while(r>=0.000001) { h-=2*r; d+=2*r; r=h/H*R; } printf("%13lf\n",d*M_PI); if(t) cout<<"\n"; } return 0; } |