Advertisement
malixds_

Untitled

Feb 21st, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. class triangle
  6. {
  7. public:
  8.     int a, b, c, p, P;
  9.     float S;
  10.    
  11.     void per()
  12.     {
  13.         P = a + b + c;
  14.         cout << "P = " << P << endl;
  15.         p = P / 2;
  16.     }
  17.  
  18.     void square()
  19.  
  20.     {
  21.         S = sqrt(p * (p - a) * (p - b) * (p - c));
  22.         cout << "S = " << S;
  23.     }
  24. };
  25.  
  26. int main()
  27. {
  28.     triangle today;
  29.     cin >> today.a;
  30.     cin >> today.b;
  31.     cin >> today.c;
  32.     today.per();
  33.     today.square();
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement