Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. bool triunghiuri(int a, int b, int c);
  5. int main()
  6. {
  7. int n, a[1000], i, k, j,c=0 ;
  8. cin >> n;
  9. for(i=1; i<=n ; i++)
  10. cin >>a[i];
  11. for(i=1; i<= n-2; i++)
  12. for(j=i+1; j<=n-1; j++)
  13. for(k=j+1; k <=n;k++)
  14. if(triunghiuri(a[i], a[j], a[k])==1)
  15. c++;
  16. cout << c;
  17.  
  18.  
  19. return 0;
  20. }
  21. bool triunghiuri( int a , int b, int c)
  22. {
  23. if(a+b>c && a+c>b && b+c > a)
  24. return true;
  25. else
  26. return false;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement