#include #include using namespace std; double otrezok(double x1, double y1, double x2, double y2) { double result; result = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)); return result; } bool IsTriangle(double a, double b, double c) { double eps = 1e-3; // точность вычислений до одной тысячной return (b + c - a > eps) && (a + c - b > eps) && (a + b - c > eps); } int main() { const int n = 4; double x[n], y[n], a, b, c; int count = 0; cout << "Input coords of points:" << endl; for (int i = 0; i < n; ++i) { cout << "Point " << i + 1 << endl; cout << "\tx" << i + 1 << ": "; cin >> x[i]; cout << "\ty" << i + 1 << ": "; cin >> y[i]; } for (int i = 0; i < n - 2; ++i) for (int j = i + 1; j < n - 1; ++j) for (int k = j + 1; k < n; ++k) { a = otrezok(x[i], y[i], x[j], y[j]); b = otrezok(x[j], y[j], x[k], y[k]); c = otrezok(x[i], y[i], x[k], y[k]); if (IsTriangle(a, b, c)) ++count; } cout << "Number of triangles: " << count << endl; system("pause"); }