How to calculate the area and perimeter of a triangle on 3 sides? Check whether it is possible to create?
Found and slightly redone this example
#include "stdafx.h" #include "iostream" #include "math.h" #include "conio.h" using namespace std; float qwer(float x1, float x2, float y1, float y2) { float d; d = sqrt(y2 - y1)*(y2 - y1) + (x2 - x1)*(x2 - x1); return d; } float per(float a, float b, float c) { return (a + b + c) / 2; } int main() { setlocale(LC_ALL, "Rus"); float x[3], y[3]; int i; for (i = 0; i < 3; i++) { cout << "Введите координаты " << i + 1 << " точки: "; cin >> x[i] >> y[i]; } float a, b, c; a = qwer(x[0], x[1], y[0], y[1]); b = qwer(x[1], x[2], y[1], y[2]); c = qwer(x[2], x[0], y[2], y[0]); float pt; pt = (a, b, c); cout << "Площадь треугольники" << sqrt(pt*(pt - a)*(pt - b)*(pt - c)) << endl; _getch(); return 0; } but after entering the values, that’s what
Введите координаты 1 точки: 1 2 Введите координаты 2 точки: 3 -1 Введите координаты 3 точки: 2 5 Площадь треугольника-nan(ind)
d = sqrt(y2 - y1)*(y2 - y1) + (x2 - x1)*(x2 - x1);And what shouldpt = (a, b, c);meanpt = (a, b, c);(which actually meanspt = c;) - generally getting lost ... - Harrypt = c;change and add variable above?float c;- user277573pt=((a,b,c)+(c,a,b)+(b,c,a))/2- vp_arthpt = ...just skipped the call to the per function defined above. Brackets - call options just. - vp_arth