Advertisement
inhuman_Arif

Untitled

Jan 18th, 2021
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. double theta(double a,double b,double c)
  8. {
  9.     double ang=0;
  10.     ang += acos(((a*a)+(b*b)-(c*c))/(2*a*b));
  11.     return ang;
  12. }
  13.  
  14. int main()
  15. {
  16.     int tc,c=1;
  17.     cin >> tc;
  18.     while(tc--)
  19.     {
  20.         double r1,r2,r3,x,y,z;
  21.         cin >> r1 >> r2 >> r3;
  22.         x = r1+r2;
  23.         y = r2+r3;
  24.         z = r1+r3;
  25.         double peri_tri, s;
  26.         peri_tri = x+y+z;
  27.         s = peri_tri/2;
  28.         double area_t = 0;
  29.         area_t += sqrt(s*(s-x)*(s-y)*(s-z));
  30.         double sector_c = 0;
  31.         sector_c += (.5*r1*r1*theta(x,y,z))+(.5*r2*r2*theta(y,z,x))+(.5*r3*r3*theta(x,z,y));
  32.         double area_d = 0;
  33.         area_d += area_t - sector_c;
  34.         printf("Case %d: %lf\n",c++,area_d);
  35.     }
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement