Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Triunghi {
- private:
- float a;
- float b;
- float c;
- static float checkA;
- static float checkB;
- static float checkC;
- public:
- Triunghi(float a, float b, float c);
- static bool verifica();
- void arie();
- void perimetru();
- void esteDreptunghic();
- };
- float Triunghi::checkA = 0;
- float Triunghi::checkB = 0;
- float Triunghi::checkC = 0;
- Triunghi::Triunghi(float a, float b, float c) {
- this->a = a;
- this->b = b;
- this->c = c;
- checkA = a;
- checkB = b;
- checkC = c;
- }
- void Triunghi::arie() {
- float p = (a + b + c) / 2;
- cout << "Aria triunghiului este : " << sqrt(p*(p - a)*(p - b)*(p - c));
- }
- void Triunghi::perimetru() {
- cout << "\nPerimetrul triunghilui este : " << a + b + c;
- }
- void Triunghi::esteDreptunghic() {
- float x = pow(c,2);
- float y = pow(a, 2) + pow(b, 2);
- if (x == y) {
- cout << "\nTriunghiul este dreptunghic!";
- }
- else {
- cout << "\nTriunghiul nu este dreptunghic!";
- }
- }
- bool Triunghi::verifica() {
- if ((checkA == 0) || (checkB == 0) || (checkC == 0)) {
- return false;
- }
- else {
- return true;
- }
- }
- void main() {
- Triunghi a(3,4,5);
- if (a.verifica() == false) {
- cout << "Laturile date nu pot forma un triunghi!\n";
- }
- else {
- a.arie();
- a.perimetru();
- a.esteDreptunghic();
- }
- cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement