#include <iostream>
#include <cmath>
using namespace std;
int
main(void)
{
double dStranicaA;
cout<<"Unesite stranicu kocke->";
cin>>dStranicaA;
cout<<"Stranice kocke je: \n";
cout<<"a ="<<dStranicaA<<endl;
cout<<"Zapremina ="<<pow(dStranicaA,3)<<endl;
cout<<"Povrsina ="<<6*pow(dStranicaA,2)<<endl;
cout<<"Prostorna dijagonala ="<<sqrt(3*pow(dStranicaA,2))<<endl;
cout<<"Poprecni presjek ="<<dStranicaA*sqrt(2*pow(dStranicaA,2))<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|
#include <iostream>
#include <cmath>
using namespace std;
class CKocka
{
private:
double dA;
public:
CKocka(double a=1){dA=a;}
~CKocka(){};
double StranicaA(void) { return dA;}
double Zapremina(void) { return pow(dA,3);}
double Povrsina(void) { return 6*pow(dA,2);}
double ProstornaDijagonala(void) { return sqrt(3*pow(dA,2));}
double PoprecniPresjek(void) { return dA*sqrt(2*pow(dA,2));}
};
int
main(void)
{
double dStranicaA;
cout<<"Unesite stranicu kocke->";
cin>>dStranicaA;
CKocka Kocka(dStranicaA);
cout<<"Stranica kocke je:"<<endl;
cout<<"a = "<<Kocka.StranicaA()<<endl;
cout<<"Zapremina ="<<Kocka.Zapremina()<<endl;
cout<<"Povrsina ="<<Kocka.Povrsina()<<endl;
cout<<"Prostorna dijgonala ="<<Kocka.ProstornaDijagonala()<<endl;
cout<<"Poprecni presjek ="<<Kocka.PoprecniPresjek()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|