0% found this document useful (0 votes)
10 views1 page

1

The document contains C++ code to calculate the total area of three triangles (ABC, CDE, ACE) by first calculating the distances between points and then using Heron's formula. It defines structs for points, functions to calculate distances and areas, reads in point data, calculates individual and total areas, and outputs the result.

Uploaded by

iulia banaru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

1

The document contains C++ code to calculate the total area of three triangles (ABC, CDE, ACE) by first calculating the distances between points and then using Heron's formula. It defines structs for points, functions to calculate distances and areas, reads in point data, calculates individual and total areas, and outputs the result.

Uploaded by

iulia banaru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream>

#include<cmath>
using namespace std;
float lab, lac, lae, lbc, lce, lcd, lde;
float A1,A2,A3,At;
struct punct{
float x,y;
};
punct A,B,C,D,E;
void citeste(){
cin>>A.x>>A.y;
cin>>B.x>>B.y;
cin>>C.x>>C.y;
cin>>D.x>>D.y;
cin>>E.x>>E.y;
}
float dist(float x1, float y1, float x2, float y2 ){
float d;
d=(float) sqrt(pow(x2-x1,2)+pow(y2-y1,2));
return d;
}
int aria(float la, float lb, float lc){
float p, A;
p=(float) (la+lb+lc)/2;
A=(float) sqrt(p*(p-la)*(p-lb)*(p-lc));
return A;
}
int main(){
citeste();
//triunghiul ABC
lab=dist(A.x,A.y,B.x,B.y);
lbc=dist(B.x,B.y,C.x,C.y);
lac=dist(A.x,A.y,C.x,C.y);
A1=aria(lab,lbc,lac);
//triunghiul CDE
lcd=dist(C.x,C.y,D.x,D.y);
lde=dist(D.x,D.y,E.x,E.y);
lce=dist(C.x,C.y,E.x,E.y);
A2=aria(lcd,lde,lce);
//triunghiul ACE
lae=dist(A.x,A.y,E.x,E.y);
A3=aria(lac,lce,lae);
At=A1+A2+A3;
cout<<"At="<<At<<endl;
}

You might also like