#include <iostream>
#include <cmath>
using namespace std;
int
main(void)
{
double dStranicaA;
cout<<"Unesite stranicu kvadrata->";
cin>>dStranicaA;
cout<<"Stranice kvadrata je: \n";
cout<<"a ="<<dStranicaA<<endl;
cout<<"Povrsina ="<<pow(dStranicaA,2)<<endl;
cout<<"Obim ="<<4*dStranicaA<<endl;
cout<<"Dijagonala ="<<sqrt(2*pow(dStranicaA,2))<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|
#include <iostream>
#include <cmath>
using namespace std;
class CKvadrat
{
private:
double dA;
public:
CKvadrat( double a=1){dA=a;}
~CKvadrat(){};
double StranicaA(void) { return dA;}
double Povrsina(void) { return pow(dA,2);}
double Obim(void) { return 4*dA;}
double Dijagonala(void){ return (sqrt(2*pow(dA,2)));}
};
int
main(void)
{
double dStranicaA;
cout<<"Unesite stranicu kvadrata->";
cin>>dStranicaA;
CKvadrat Kvadrat(dStranicaA);
cout<<"Stranica kvadrat je:"<<endl;
cout<<"a = "<<Kvadrat.StranicaA()<<endl;
cout<<"Povrsina ="<<Kvadrat.Povrsina()<<endl;
cout<<"Obim ="<<Kvadrat.Obim()<<endl;
cout<<"Dijagonala ="<<Kvadrat.Dijagonala()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|