Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- struct Point
- {
- float x;
- float y;
- };
- float dlugosc(Point a, Point b)
- {
- float dlugosc;
- dlugosc=sqrt(((a.x-b.x)*(a.x-b.x))+((a.y-b.y)*(a.y-b.y)));
- return dlugosc;
- }
- float poletrojkata(Point a, Point b, Point c)
- {
- float A = dlugosc(b, c);
- float B = dlugosc(a, c);
- float C = dlugosc(a, b);
- float p;
- p=(A + B + C)/2;
- return sqrt(p*(p-A)*(p-B)*(p-C));
- }
- int main()
- {
- Point a, b, c;
- a.x = 0;
- a.y = 0;
- b.x = 4;
- b.y = 0;
- c.x = 0;
- c.y = 3;
- cout << poletrojkata(a, b, c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement