#include <bits/stdc++.h>
using namespace std;
class Circle
{
private:
double radius;
public:
static double PI;
Circle(double a=2):radius(a){}
double getRadius() const
{
return radius;
}
double getArea() const
{
return 3.14*radius*radius;
}
};
double Circle::PI = 3.14;
int main()
{
double radius;
cout<<"PI="<<Circle::PI<<endl;
const Circle c1(2);
cout<<"radius="<<c1.getRadius();
cout<<",area="<<c1.getArea()<<endl;
cin>>radius;
Circle c2(radius);
cout<<"radius="<<c2.getRadius();
cout<<",area="<<c2.getArea()<<endl;
return 0;
}
//来自Fivelish
山科oj2197 圆的面积
最新推荐文章于 2022-01-25 19:51:24 发布