Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     setlocale(LC_ALL, "RUS");
  10.     // Координаты x и y для точке
  11.     double x[6];
  12.     double y[6];
  13.     cout << "Введите координаты первого треугольника: " << endl;
  14.     for (int i = 0; i < 3; ++i)
  15.     {
  16.         cout << "x" << i + 1 << ": ";
  17.         cin >> x[i];
  18.         cout << "y" << i + 1 << ": ";
  19.         cin >> y[i];
  20.     }
  21.     cout << "Введите координаты второго треугольника: " << endl;
  22.     for (int i = 3; i < 6; ++i)
  23.     {
  24.         cout << "x" << i + 1 << ": ";
  25.         cin >> x[i];
  26.         cout << "y" << i + 1 << ": ";
  27.         cin >> y[i];
  28.     }
  29.  
  30.     double S1 = (x[0] - x[2])*(y[1] - y[2]) - (x[1] - x[2])*(y[0] - y[2]);
  31.     S1 = abs(S1 * 0.5);
  32.     double S2 = (x[3] - x[5])*(y[4] - y[5]) - (x[4] - x[5])*(y[3] - y[5]);
  33.     S2 = abs(S2 * 0.5);
  34.     if (S1 > S2)
  35.     {
  36.         cout << "Площадь первого треугольника больше" << endl;
  37.     } else
  38.         if (S1 == S2)
  39.         {
  40.             cout << "Площади равны" << endl;
  41.         }
  42.         else
  43.         {
  44.             cout << "Площадь второго треугольника больше" << endl;
  45.         }
  46.     cout << "S1: " << S1 << endl << "S2: " << S2 << endl;
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement