#ifndef TROUGAO_HPP_INCLUDED
#define TROUGAO_HPP_INCLUDED
#include <math.h>
#include <iostream>
using namespace std;
class Trougao {
private:
double a;
double b;
double c;
public:
Trougao() {a=3;b=4;c=5;}
void setA(double aa) {a=aa;}
void setB(double bb) {b=bb;}
void setC(double cc) {c=cc;}
double getA() const {return a;}
double getB() const {return b;}
double getC() const {return c;}
double getO() const;
double getP() const;
};
#endif // TROUGAO_HPP_INCLUDED
-------------------------------
#ifndef TROUGAO_CPP_INCLUDED
#define TROUGAO_CPP_INCLUDED
#include "trougao.hpp"
double Trougao::getO() const {
return a+b+c;
}
double Trougao::getP() const {
double s=(a+b+c)/2;
return sqrt(s*(s-a)*(s-b)*(s-c));
}
#endif // TROUGAO_CPP_INCLUDED
-------------------------------
#include "trougao.hpp"
int main() {
Trougao t;
cout<<"Duzina stranice a:"<<t.getA()<<endl;
cout<<"Duzina stranice b:"<<t.getB()<<endl;
cout<<"Duzina stranice c:"<<t.getC()<<endl;
cout<<"Obim:"<<t.getO()<<endl;
cout<<"Povrsina:"<<t.getP()<<endl;
return 0;
}
#define TROUGAO_HPP_INCLUDED
#include <math.h>
#include <iostream>
using namespace std;
class Trougao {
private:
double a;
double b;
double c;
public:
Trougao() {a=3;b=4;c=5;}
void setA(double aa) {a=aa;}
void setB(double bb) {b=bb;}
void setC(double cc) {c=cc;}
double getA() const {return a;}
double getB() const {return b;}
double getC() const {return c;}
double getO() const;
double getP() const;
};
#endif // TROUGAO_HPP_INCLUDED
-------------------------------
#ifndef TROUGAO_CPP_INCLUDED
#define TROUGAO_CPP_INCLUDED
#include "trougao.hpp"
double Trougao::getO() const {
return a+b+c;
}
double Trougao::getP() const {
double s=(a+b+c)/2;
return sqrt(s*(s-a)*(s-b)*(s-c));
}
#endif // TROUGAO_CPP_INCLUDED
-------------------------------
#include "trougao.hpp"
int main() {
Trougao t;
cout<<"Duzina stranice a:"<<t.getA()<<endl;
cout<<"Duzina stranice b:"<<t.getB()<<endl;
cout<<"Duzina stranice c:"<<t.getC()<<endl;
cout<<"Obim:"<<t.getO()<<endl;
cout<<"Povrsina:"<<t.getP()<<endl;
return 0;
}
Нема коментара:
Постави коментар