Добрый день! К сожалению я не работаю с C++, но если это то вот эта задача в Pascal VAR a,b,c,d:REAL; PROCEDURE Print_S(x,y,z:REAL); VAR p,S:REAL; begin If ((x+y)>z) and ((x+z)>y) and ((y+z)>x) then begin p:=x+y+z; S:=SQRT(p*(p-x)*(p-y)*(p-z)); WriteLn('S= ',S); end else Writeln('Треугольник не существует!'); end; BEGIN Write('a= '); ReadLn(a); Write('b= '); ReadLn(b); Write('c= '); ReadLn(c); Write('d= '); ReadLn(d); WriteLn; WriteLn('Стороны ',a,'; ',b,'; ',c); Print_S(a,b,c); WriteLn; WriteLn('Стороны ',a,'; ',b,'; ',d); Print_S(a,b,d); WriteLn; WriteLn('Стороны ',a,'; ',c,'; ',d); Print_S(a,c,d); WriteLn; WriteLn('Стороны ',b,'; ',c,'; ',d); Print_S(b,c,d); END.
void TriangleArea(double a, double b, double c) { double p = (a + b + c) / 2; double ss = p * (p - a) * (p - b) * (p - c); // Using Heron's formula if (ss > 0) cout << "Area of triangle = " << sqrt(ss); else cout << "The three sides will not form a triangle."; }
cout << "\n\nThree side lengths to a triangle (a, b, c):\n"; TriangleArea(a, b, c); cout << "\n\nThree side lengths to a triangle (a, b, d):\n"; TriangleArea(a, b, d); cout << "\n\nThree side lengths to a triangle (b, c, d):\n"; TriangleArea(b, c, d); cout << "\n\nThree side lengths to a triangle (a, c, d):\n"; TriangleArea(a, c, d); cout << "\n\n"; }
VAR a,b,c,d:REAL;
PROCEDURE Print_S(x,y,z:REAL);
VAR p,S:REAL;
begin If ((x+y)>z) and ((x+z)>y) and ((y+z)>x) then
begin
p:=x+y+z;
S:=SQRT(p*(p-x)*(p-y)*(p-z));
WriteLn('S= ',S);
end
else
Writeln('Треугольник не существует!');
end;
BEGIN Write('a= ');
ReadLn(a);
Write('b= ');
ReadLn(b);
Write('c= ');
ReadLn(c);
Write('d= ');
ReadLn(d);
WriteLn;
WriteLn('Стороны ',a,'; ',b,'; ',c);
Print_S(a,b,c);
WriteLn;
WriteLn('Стороны ',a,'; ',b,'; ',d);
Print_S(a,b,d);
WriteLn;
WriteLn('Стороны ',a,'; ',c,'; ',d);
Print_S(a,c,d);
WriteLn;
WriteLn('Стороны ',b,'; ',c,'; ',d);
Print_S(b,c,d);
END.
using namespace std;
void TriangleArea(double a, double b, double c)
{
double p = (a + b + c) / 2;
double ss = p * (p - a) * (p - b) * (p - c); // Using Heron's formula
if (ss > 0)
cout << "Area of triangle = " << sqrt(ss);
else
cout << "The three sides will not form a triangle.";
}
void main()
{
double a, b, c, d;
cout << "a = ";
cin >> a;
cout << "b = ";
cin >> b;
cout << "c = ";
cin >> c;
cout << "d = ";
cin >> d;
cout << "\n\nThree side lengths to a triangle (a, b, c):\n";
TriangleArea(a, b, c);
cout << "\n\nThree side lengths to a triangle (a, b, d):\n";
TriangleArea(a, b, d);
cout << "\n\nThree side lengths to a triangle (b, c, d):\n";
TriangleArea(b, c, d);
cout << "\n\nThree side lengths to a triangle (a, c, d):\n";
TriangleArea(a, c, d);
cout << "\n\n";
}