Написать программу в С++ Описать функцию Otr(Ax,Bx,Ay,By) вещественного типа находящую длину отрезка AB на плоскости по координатам его концов |AB|=sqrt((Ax-Bx)^2+(Ay-By)^2 )(Ax,Ay,Bx,By)- вещественны параметры) с помощью этой функции найти длины отрезков AB,AC,AD, если с клавиатуры заданы координаты точек, A,B,C,D.
cout << "Enter the coordinates of point A (Ax Ay): "; cin >> Ax >> Ay; cout << "Enter the coordinates of point B (Bx By): "; cin >> Bx >> By; cout << "Enter the coordinates of point C (Cx Cy): "; cin >> Cx >> Cy; cout << "Enter the coordinates of point D (Dx Dy): "; cin >> Dx >> Dy; double AB = Otr(Ax, Bx, Ay, By); double AC = Otr(Ax, Cx, Ay, Cy); double AD = Otr(Ax, Dx, Ay, Dy); cout << "Length of segment AB: " << AB << endl; cout << "Length of segment AC: " << AC << endl; cout << "Length of segment AD: " << AD << endl; return 0;
using namespace std;
double Otr(double Ax, double Bx, double Ay, double By) {
return sqrt((Ax - Bx)(Ax - Bx) + (Ay - By)(Ay - By));
}
int main() {
cout << "Enter the coordinates of point A (Ax Ay): ";double Ax, Ay, Bx, By, Cx, Cy, Dx, Dy;
cin >> Ax >> Ay;
cout << "Enter the coordinates of point B (Bx By): ";
cin >> Bx >> By;
cout << "Enter the coordinates of point C (Cx Cy): ";
cin >> Cx >> Cy;
cout << "Enter the coordinates of point D (Dx Dy): ";
cin >> Dx >> Dy;
double AB = Otr(Ax, Bx, Ay, By);
double AC = Otr(Ax, Cx, Ay, Cy);
double AD = Otr(Ax, Dx, Ay, Dy);
cout << "Length of segment AB: " << AB << endl;
cout << "Length of segment AC: " << AC << endl;
cout << "Length of segment AD: " << AD << endl;
return 0;
}