Advertisement
MeehoweCK

Untitled

May 16th, 2023
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. struct Point
  7. {
  8.     float x;
  9.     float y;
  10. };
  11.  
  12. float dlugosc(Point a, Point b)
  13. {
  14.     float dlugosc;
  15.     dlugosc=sqrt(((a.x-b.x)*(a.x-b.x))+((a.y-b.y)*(a.y-b.y)));
  16.     return dlugosc;
  17. }
  18.  
  19. float poletrojkata(Point a, Point b, Point c)
  20. {
  21.     float A = dlugosc(b, c);
  22.     float B = dlugosc(a, c);
  23.     float C = dlugosc(a, b);
  24.  
  25.     float p;
  26.     p=(A + B + C)/2;
  27.     return sqrt(p*(p-A)*(p-B)*(p-C));
  28. }
  29.  
  30. int main()
  31. {
  32.     Point a, b, c;
  33.     a.x = 0;
  34.     a.y = 0;
  35.     b.x = 4;
  36.     b.y = 0;
  37.     c.x = 0;
  38.     c.y = 3;
  39.     cout << poletrojkata(a, b, c);
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement