#includeusingnamespacestd;#definePI3.141592635classCircle{public:Circle():_r(0.f){}Circle(doubler):_r(r){}Circle(constCircle&circle){this->_r=circle._r;}voidsetRadius(doubler){this->_r=r;}doubleArea(){returnPI*this->_r*this->_r;}doubleCircumference(){return2*PI*this->_r;}private:double_r;};intmain(){Circlec1;doublex;cin>>x;c1.setRadius(x);cout<<"c1面积:"旅指<<c1.Area()<<endl;cout<<"c1周长:"<<c1.Circumference()<<endl;Circlec2(2*x);cout<<"c2面前镇源积:"<<c2.Area()<<endl;cout<<"c2周长:"<<c2.Circumference()<<endl;Circlec3(c1);cout<<"c3面积:"<<c3.Area()<<endl;cout<<"慧态c3周长:"<<c3.Circumference()<<endl;return0;}
#include <iostream>using namespace std
#define PI 3.141592635
class Circle
{
public:
Circle() : _r(0.f){}
Circle(double r) : _r(r){}
Circle(const Circle& circle)
{
this->_r = circle._r
}
void setRadius(double r)
{
this->_r = r
}
double Area()
{
return PI * this->_r * this->_r
}
double Circumference()
{
冲桥 老雹return 2 * PI * this->_r
}
private:
double _r
}
int main()
{
Circle c1
double x
cin >> x
c1.setRadius(x)
cout << "c1面积:" 侍判帆<< c1.Area() << endl
cout << "c1周长:" << c1.Circumference() << endl
Circle c2(2 * x)
cout << "c2面积:" << c2.Area() << endl
cout << "c2周长:" << c2.Circumference() << endl
Circle c3(c1)
cout << "c3面积:" << c3.Area() << endl
cout << "c3周长:" << c3.Circumference() << endl
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)