#include <iostream>
#include <cmath>
using namespace std;
int
main(void)
{
double dStranicaA;
cout<<"Unesite stranicu a prizme->";
cin>>dStranicaA;
double dStranicaB;
cout<<"Unesite stranicu b prizme->";
cin>>dStranicaB;
double dVisinaH;
cout<<"Unesite visinu h prizme->";
cin>>dVisinaH;
cout<<"Stranice prizme su: \n";
cout<<"a ="<<dStranicaA<<endl;
cout<<"b ="<<dStranicaB<<endl;
cout<<"Visina ="<<dVisinaH<<endl;
cout<<"Povrsina ="<<2*(dStranicaA*dStranicaB+dStranicaA*dVisinaH+dStranicaB*dVisinaH)<<endl;
cout<<"Zapremina ="<<dStranicaA*dStranicaB*dVisinaH<<endl;
cout<<"Prostorna dijagonala ="<<sqrt(pow(dStranicaA,2)+pow(dStranicaB,2)+pow(dVisinaH,2))<<endl;
cout<<"Poprecni presjek ="<<dVisinaH*sqrt(pow(dStranicaA,2)+pow(dStranicaB,2))<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|
#include <iostream>
#include <cmath>
using namespace std;
class CPrizma
{
private:
double dA, dB, dH;
public:
CPrizma(double a=1, double b=1, double h=1){dA=a; dB=b; dH=h;};
~CPrizma(){};
double StranicaA(void) { return dA;}
double StranicaB(void) { return dB;}
double VisinaH(void) { return dH;}
double Povrsina(void) { return 2*(dA*dB+dA*dH+dB*dH);}
double Zapremina(void) { return dA*dB*dH;}
double ProstornaDijagonala(void){ return sqrt(pow(dA,2)+pow(dB,2)+pow(dH,2));}
double PoprecniPresjek(void) { return dH*sqrt(pow(dA,2)+pow(dB,2));}
};
int
main(void)
{
double dStranicaA;
cout<<"Unesite stranicu a prizme->";
cin>>dStranicaA;
double dStranicaB;
cout<<"Unesite stranicu b prizme->";
cin>>dStranicaB;
double dVisinaH;
cout<<"Unesite visinu h prizme->";
cin>>dVisinaH;
CPrizma Prizma(dStranicaA,dStranicaB,dVisinaH);
cout<<"Stranice prizme su:"<<endl;
cout<<"a = "<<Prizma.StranicaA()<<endl;
cout<<"b = "<<Prizma.StranicaB()<<endl;
cout<<"Visina = "<<Prizma.VisinaH()<<endl;
cout<<"Povrsina ="<<Prizma.Povrsina()<<endl;
cout<<"Zapremina ="<<Prizma.Zapremina()<<endl;
cout<<"Prostorna dijgonala ="<<Prizma.ProstornaDijagonala()<<endl;
cout<<"Poprecni presjek ="<<Prizma.PoprecniPresjek()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|