devzdesilva

Angle Of Triangles SLHACK1.0

Feb 7th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. bool invalid(double a, double b, double c){
  6.     if(a+b > c && a+c > b && b+c > a)return false;
  7.     return true;
  8. }
  9.  
  10. int main(){
  11.     int n;
  12.     cin>>n;
  13.     double ar[n];
  14.     for(int i=0;i<n;i++)cin>>ar[i];
  15.    
  16.     int ac=0,ri=0,ob=0;
  17.     double a,b,c,h;
  18.    
  19.     for(int i=0;i<n;i++){
  20.         for(int j=i+1;j<n;j++){
  21.             for(int k=j+1;k<n;k++){
  22.                 a=ar[i];
  23.                 b=ar[j];
  24.                 c=ar[k];
  25.                 if(invalid(a,b,c))continue;
  26.                 if(ar[i] >= ar[j] && ar[i] >= ar[k]){
  27.                     c=ar[i];
  28.                     a=ar[j];
  29.                     b=ar[k];
  30.                 }else if(ar[j] >= ar[i] && ar[j] >= ar[k]){
  31.                     c=ar[j];
  32.                     a=ar[i];
  33.                     b=ar[k];
  34.                 }
  35.                 h= sqrt(a*a + b*b);
  36.                 //cout<<h<<" "<<c<<endl;
  37.                 if (h==c)ri++;
  38.                 else if(h < c)ob++;
  39.                 else ac++;
  40.             }
  41.         }
  42.     }
  43.     cout<<ac<<" "<<ri<<" "<<ob<<endl;
  44.     return 0;
  45. }
Add Comment
Please, Sign In to add comment