Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. bool isTriangle(double, double, double);
  7. bool isRectangular(double a, double b, double c);
  8.  
  9. const double e = 0.0001;
  10.  
  11. int main(const int argc, char ** argv)
  12. {
  13. double a, b, c;
  14.  
  15. cin >> a >> b >> c;
  16.  
  17. if (isTriangle(a, b, c)) {
  18. if (isRectangular(a, b, c) || isRectangular(a, c, b) || isRectangular(b, a, c) || isRectangular(b, c, a) || isRectangular(c, a, b) || isRectangular(c, b, a)) {
  19. cout << "YES";
  20. }
  21. }
  22. else cout << "NO";
  23.  
  24. return 0;
  25. }
  26.  
  27. bool isTriangle(double a, double b, double c) {
  28. if (a + b > c && b + c > a && a + c > b) return true;
  29. else return false;
  30. }
  31.  
  32. bool isRectangular(double a, double b, double c) {
  33. if (e > abs(b * b + c * c - a * a) || e > abs(b * b + a * a - c * c) || e > abs(a * a + c * c - b * b)) { // равносильно теореме Пифагора, но с погрешностью e
  34. return true;
  35. }
  36. else return false;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement