#include <iostream>
#include <cmath>
#define PI 3.141592
using namespace std;
int
main(void)
{
double dPoluprecnik;
cout<<"Unesite poluprecnik->";
cin>>dPoluprecnik;
cout<<"Precnik iznosi: \n";
cout<<"R = "<<dPoluprecnik<<endl;
cout<<"Povrsina ="<<pow(dPoluprecnik,2)*PI<<endl;
cout<<"Obim ="<<2*dPoluprecnik*PI<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|
#include <iostream>
#include <cmath>
#define PI 3.141592
using namespace std;
class CKrug
{
private:
double dR;
public:
CKrug( double r=1){dR=r;}
~CKrug(){};
double PostaviPoluprecnik(void) { return dR; }
double Povrsina(void) { return pow(dR,2)*PI; }
double Obim(void) { return 2*dR*PI;}
};
int
main(void)
{
double dPoluprecnik;
cout<<"Unesite poluprecnik->";
cin>>dPoluprecnik;
CKrug Krug(dPoluprecnik);
cout<<"Poluprecnik iznosi: \n";
cout<<"R = "<<Krug.PostaviPoluprecnik()<<endl;
cout<<"Povrsina ="<<Krug.Povrsina()<<endl;
cout<<"Obim ="<<Krug.Obim()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
|