Advertisement
AntonioVillanueva

Triangulo

Jun 5th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. class triangulo{
  6.     public:
  7.     triangulo(double base,double altura,double cateto);
  8.     double area();
  9.     double perimetro();
  10.     private:
  11.     double base,altura,cateto;
  12. };
  13. //-----------------------------------------------------------------------------------------------
  14.     triangulo::triangulo(double base,double altura,double cateto):base(base),altura(altura),cateto(cateto){}
  15.     double triangulo::area(){return (base*altura/2);}
  16.     double triangulo::perimetro(){return base+2*cateto;}
  17. //-----------------------------------------------------------------------------------------------
  18. //-----------------------------------------------------------------------------------------------  
  19. int main (){
  20.     triangulo a (10,42,43.17);//creo un triangulo de base 10  altura 42 cateto 43.17
  21.     cout <<"area es "<<a.area()<<endl;
  22.     cout <<"su perimetro "<<a.perimetro()<<endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement