Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RUS");
- // Координаты x и y для точке
- double x[6];
- double y[6];
- cout << "Введите координаты первого треугольника: " << endl;
- for (int i = 0; i < 3; ++i)
- {
- cout << "x" << i + 1 << ": ";
- cin >> x[i];
- cout << "y" << i + 1 << ": ";
- cin >> y[i];
- }
- cout << "Введите координаты второго треугольника: " << endl;
- for (int i = 3; i < 6; ++i)
- {
- cout << "x" << i + 1 << ": ";
- cin >> x[i];
- cout << "y" << i + 1 << ": ";
- cin >> y[i];
- }
- double S1 = (x[0] - x[2])*(y[1] - y[2]) - (x[1] - x[2])*(y[0] - y[2]);
- S1 = abs(S1 * 0.5);
- double S2 = (x[3] - x[5])*(y[4] - y[5]) - (x[4] - x[5])*(y[3] - y[5]);
- S2 = abs(S2 * 0.5);
- if (S1 > S2)
- {
- cout << "Площадь первого треугольника больше" << endl;
- } else
- if (S1 == S2)
- {
- cout << "Площади равны" << endl;
- }
- else
- {
- cout << "Площадь второго треугольника больше" << endl;
- }
- cout << "S1: " << S1 << endl << "S2: " << S2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement