Advertisement
Masud26

Triangle.

Oct 23rd, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. bool checkValidity(int a, int b, int c)
  4. {
  5.     if (a + b <= c || a + c <= b || b + c <= a)
  6.         return false;
  7.     else
  8.         return true;
  9. }
  10. using namespace std;
  11. int main () {
  12.      int i,N;
  13.      double area,s;
  14.      double a,b,c;
  15.      cin>>N;
  16.      for(int i=1;i<=N;i++){
  17.      cin>>a>>b>>c;
  18.  
  19.       if (checkValidity(a, b, c)){
  20.  s=(a+b+c)/2;
  21.      area=sqrt(s *(s-a)*(s-b)*(s-c));
  22.       printf("%.2lf\n",area);
  23.       }
  24.  
  25.     else
  26.       printf("Oh, No!\n");
  27.  
  28.      }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement