Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class triangulo{
- public:
- triangulo(double base,double altura,double cateto);
- double area();
- double perimetro();
- private:
- double base,altura,cateto;
- };
- //-----------------------------------------------------------------------------------------------
- triangulo::triangulo(double base,double altura,double cateto):base(base),altura(altura),cateto(cateto){}
- double triangulo::area(){return (base*altura/2);}
- double triangulo::perimetro(){return base+2*cateto;}
- //-----------------------------------------------------------------------------------------------
- //-----------------------------------------------------------------------------------------------
- int main (){
- triangulo a (10,42,43.17);//creo un triangulo de base 10 altura 42 cateto 43.17
- cout <<"area es "<<a.area()<<endl;
- cout <<"su perimetro "<<a.perimetro()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement