Vla_DOS

Untitled

Dec 22nd, 2022
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. class Triangle {
  7. private:
  8.     int x1 = 0, x2 = 0, x3 = 0, x4 = 0, y1 = 0, y2 = 0, y3 = 0, y4 = 0;
  9.  
  10. public:
  11.  
  12.     Triangle() {}
  13.  
  14.     Triangle(int _x1, int _x2, int _x3, int _x4, int _y1, int _y2, int _y3, int _y4) {
  15.         x1 = _x1;
  16.         x2 = _x2;
  17.         x3 = _x3;
  18.         x4 = _x4;
  19.         y1 = _y2;
  20.         y3 = _y3;
  21.         y4 = _y4;
  22.     }
  23.  
  24.     double GetAB() {
  25.         return sqrt(pow(y2 - y1, 2) + pow(x2 - x1, 2));
  26.     }
  27.     double GetBC() {
  28.         return sqrt(pow(y3 - y2, 2) + pow(x3 - x2, 2));
  29.     }
  30.     double Parimeter() {
  31.         return 2 * (GetAB() + GetBC());
  32.     }
  33.     double Square() {
  34.         return GetAB() * GetBC();
  35.     }
  36.  
  37. };
  38.  
  39. int main()
  40. {
  41.     int x1 = -3, x2 = -3, x3 = 5, x4 = 5, y1 = -1, y2 = 3, y3 = 3, y4 = -1;
  42.  
  43.     Triangle triangle(x1, x2, x3, x4, y1, y2, y3, y4);
  44.     cout << "S = " << triangle.Square() << endl;
  45.     cout << "P = " << triangle.Parimeter() << endl;
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment