#include #include using namespace std; struct Punto2D { char nome; float x; float y; }; void mostraPunto2D(Punto2D p); void mostraPunto2Dbis(char n, float x, float y); double distanza2D(Punto2D p1, Punto2D p2); int main () { Punto2D p[3]; p[0].nome = 'A'; p[0].x= 1.0; p[0].y= 1.0; p[1].nome = 'B'; p[1].x= 4.0; p[1].y= 5.0; p[2].nome = 'C'; p[2].x= 4.0; p[2].y= 1.0; float l[3]; l[0] = distanza2D(p[0],p[1]); l[1] = distanza2D(p[0],p[2]); l[2] = distanza2D(p[2],p[1]); for (int i=0; i<3; i++){ mostraPunto2D(p[i]); cout << ' '; } cout << endl; float P2=0; for (int i=0; i<3; i++){ cout << "l" << i+1 << "=" << l[i] << " "; P2+=l[i]; } cout << endl; cout << "2P=" << P2 << endl; return 0; } void mostraPunto2D(Punto2D p){ cout << p.nome << "(" << p.x << ", " << p.y << ")"; } void mostraPunto2Dbis(char n, float x, float y){ cout << n << "(" << x << ", " << y << ")"; } double distanza2D(Punto2D pA, Punto2D pB){ return sqrt((pow(pA.x-pB.x,2) + pow(pA.y-pB.y,2))); }