Created
April 28, 2018 04:48
-
-
Save FraGoTe/a6b912d8f597fb280ce273a6e7d8a649 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include <math.h> | |
using namespace std; | |
class Figura { | |
private: | |
float base; | |
float altura; | |
public: | |
void captura(); | |
virtual unsigned float perimetro()=0; | |
virtual unsigned float area()=0; | |
}; | |
class Rectangulo: public Figura { | |
public: | |
void imprime(); | |
unsigned float perimetro(){return 2*(base+altura);} | |
unsigned float area(){return base*altura;} | |
}; | |
class Triangulo: public Figura { | |
public: | |
void muestra(); | |
unsigned float perimetro(){return 2*sqrt(altura^2+(base/2)^2)+base;} //Usando pitágoras | |
unsigned float area(){return (base*altura)/2;} | |
}; | |
void Figura::captura() | |
{ | |
cout << "CALCULO DEL AREA Y PERIMETRO DE UN TRIANGULO ISÓSCELES Y UN RECTANGULO:" << endl; | |
cout << "escribe la altura: "; | |
cin >> altura; | |
cout << "escribe la base: "; | |
cin >> base; | |
cout << "EL PERIMETRO ES: " << perimetro(); | |
cout << "EL AREA ES: " << area(); | |
getchar(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment