#include <iostream>
#include <cmath>
using namespace std;
int
main(void)
{
double dA, dB;
double dPrva;
cout<<"Unesite prvu stranicu pravougaonika->";
cin>>dPrva;
double dDruga;
cout<<"Unesite drugu stranicu pravougaonika->";
cin>>dDruga;
cout<<"Stranice pravougaonika su: \n";
cout<<"a ="<<dA<<"b ="<<dB<<endl;
cout<<"Povrsina =<<dA*dB<<endl;
<<"Obim ="<<((double)2)*dA*dB<<endl;
<<"Dijagonala ="<<sqrt(pow(dA,2)+pow(dB,2)<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|
#include <iostream>
#include <cmath>
using namespace std;
class CPravougaonik
{
private:
double dA, dB;
public:
CPravougaonik( double a=1, double b=1){dA=a; dB=b;}
~CPravougaonik(){}
double StranicaA(void) { return dA;}
double StranicaB(void) { return dB;}
double Povrsina(void) { return dA*dB;}
double Obim(void) { return ((double)2)*dA*dB;}
double Dijagonala(void){ return (sqrt(pow(dA,2)+pow(dB,2)));}
};
int
main(void)
{
double dStranicaA;
cout<<"Unesite prvu stranicu pravougaonika->";
cin>>dStranicaA;
double dStranicaB;
cout<<"Unesite drugu stranicu pravougaonika->";
cin>>dStranicaB;
CPravougaonik Pravougaonik(dStranicaA, dStranicaB);
cout<<"Stranice pravougaonika su: \n";
cout<<"a = "<<Pravougaonik.StranicaA()<<endl;
cout<<"b = "<<Pravougaonik.StranicaB()<<endl;
cout<<"Povrsina ="<<Pravougaonik.Povrsina()<<endl;
cout<<"Obim ="<<Pravougaonik.Obim()<<endl;
cout<<"Dijgonala ="<<Pravougaonik.Dijagonala()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|