Advertisement
LegoDrifter

Triangle - Area and L

Apr 2nd, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. class Triangle{
  8. private:
  9.     int a;
  10.     int b;
  11.     int c;
  12. public:
  13.     Triangle(int a,int b,int c)
  14.     {
  15.     this->a=a;
  16.     this->b=b;
  17.     this->c=c;
  18.     }
  19.     int L(){
  20.     return
  21.     a+b+c;
  22.     }
  23.     int P(){
  24.     return sqrt(((a+b+c)/2)*(((a+b+c)/2)-a)*(((a+b+c)/2)-b)*(((a+b+c)/2)-c));
  25.     }
  26.  
  27. };
  28.  
  29. int main()
  30. {
  31.  
  32.     float a,b,c;
  33.     cin>> a >> b >> c;
  34.     Triangle object(a,b,c);
  35.     cout<< "The area of the triangle is:" << object.P() << endl;
  36.     cout<< "The perimeter of the triangle is:" << object.L() << endl;
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement