Advertisement
Guest User

Untitled

a guest
May 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. class trikampis
  6. {
  7. private:
  8. int x1, y1, x2, y2, x3, y3;
  9. double S;
  10. public:
  11. trikampis():x1(0),y1(0),x2(0),y2(0), x3(0), y3(0){}
  12. trikampis(int a, int b, int c, int d, int e, int f):x1(a),y1(b),x2(c),y2(d),x3(e),y3(f){};
  13. ~trikampis(){}
  14. void ived()
  15. {
  16. cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  17. }
  18. double plotas()
  19. {
  20. double a, b, c, p;
  21. a =sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  22. b =sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
  23. c =sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
  24. p = (a+b+c)/2.;
  25. S = sqrt(p*(p-a)*(p-b)*(p-c));
  26.  
  27. }
  28. double graz_plotas()
  29. {
  30. return S;
  31. }
  32.  
  33.  
  34. };
  35.  
  36. int main()
  37. {
  38. int n;
  39. double plot;
  40. int min = 0;
  41. cin >> n;
  42. trikampis *T = new trikampis [n];
  43. for (int i = 0; i < n; i++) {
  44. T[i].ived();
  45. plot = T[i].plotas(); }
  46.  
  47. if (plot == 0) cout << "NO";
  48. else if (plot != 0 && plot < min)
  49. cout << fixed << setprecision(2) << min;
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement