Программа Pascal. Даны координаты 3 точек x1,x2,x3, y1,y2,y3, которые представляют собой вершины треугольника. Вычислить а) Длины сторон треугольника б)Площадь треугольника
var x1, x2, x3, y1, y2, y3: real; a, b, c: real; s, p: real;
begin writeln('Enter the coordinates of the first point (x1 y1): '); readln(x1, y1); writeln('Enter the coordinates of the second point (x2 y2): '); readln(x2, y2); writeln('Enter the coordinates of the third point (x3 y3): '); readln(x3, y3);
a := sqrt(sqr(x2 - x1) + sqr(y2 - y1)); b := sqrt(sqr(x3 - x2) + sqr(y3 - y2)); c := sqrt(sqr(x1 - x3) + sqr(y1 - y3));
writeln('The lengths of the sides of the triangle are:'); writeln('Side a: ', a:0:2); writeln('Side b: ', b:0:2); writeln('Side c: ', c:0:2);
p := (a + b + c) / 2; s := sqrt(p (p - a) (p - b) * (p - c));
writeln('The area of the triangle is: ', s:0:2); end.
program TriangleProperties;
var
x1, x2, x3, y1, y2, y3: real;
a, b, c: real;
s, p: real;
begin
writeln('Enter the coordinates of the first point (x1 y1): ');
readln(x1, y1);
writeln('Enter the coordinates of the second point (x2 y2): ');
readln(x2, y2);
writeln('Enter the coordinates of the third point (x3 y3): ');
readln(x3, y3);
a := sqrt(sqr(x2 - x1) + sqr(y2 - y1));
b := sqrt(sqr(x3 - x2) + sqr(y3 - y2));
c := sqrt(sqr(x1 - x3) + sqr(y1 - y3));
writeln('The lengths of the sides of the triangle are:');
writeln('Side a: ', a:0:2);
writeln('Side b: ', b:0:2);
writeln('Side c: ', c:0:2);
p := (a + b + c) / 2;
s := sqrt(p (p - a) (p - b) * (p - c));
writeln('The area of the triangle is: ', s:0:2);
end.