C/C++

Можете пожалуйста написать код на с++

Даны длины трех отрезков a, b, c. Если можно построить треугольник по этим трем отрезкам, то вычислить его периметр и площадь.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double length(const char* msg) {
cout << msg;
double value;
cin >> value;
cin.ignore(cin.rdbuf()->in_avail());
return value;
}
int main() {
double max, per;
auto a = length("Side A: ");
per = max = a;
auto b = length("Side B: ");
per += b;
if (b > max) max = b;
auto c = length("Side C: ");
per += c;
if (c > max) max = c;
if (max >= per - max) puts("The triangle doesn't exist!");
else {
cout << "Perimeter: " << per << '\n';
auto p = per / 2;
auto s = sqrt(p * (p - a) * (p - b) * (p - c));
cout << "Area: " << fixed << setprecision(4) << s << '\n';
}
system("pause > nul");
}
Сергей Петров
Сергей Петров
58 994
Лучший ответ
Wo
Wonderer
29 440
#include
#include

using namespace std;

int main() {
double a, b, c, p, s;
cout << "Enter triangle sides:\n";
cout << "a = ";
cin >> a;
cout << "b = ";
cin >> b;
cout << "c = ";
cin >> c;
cout << "Output of the program: ";
if (a + b > c && a + c > b && b + c > a) {
p = (a + b + c) / 2;
s = sqrt(p * (p - a) * (p - b) * (p - c));
cout << s << "\n";
} else {
cerr << "There is no triangle with such sides!\n";
}
system("pause");
return 0;
}
Dima Kainazarov
Dima Kainazarov
16 997
Dima Kainazarov Короче код не заработает, сайт этот парашный удаляет часть кода, а ссылку я вставить не могу. Корояе вводишь в поиске сайт киберфорум и потом подствляешь сзади https:/"киберфорум"/cpp-beginners/thread2342505.html