#include"iostream"
#define PI 3.1415962
using namespace std;
class circle
{
private:
int r; //半径
public:
circle() //无参数构造函数以10为半径
{
r=10;
}
circle(double x) //构造函数
{
r=x;
}
double length()
{
return 2*PI*r;
}
double area()
{
return PI*r*r;
}
}
main()
{
double x;
circle a;
cout<<"默认无参数构造函数输出"<
cin>>x;
circle b(x);
cout<<"参数构造函数输出"<
#include
#define Pi 3.14;
class yuan
{
public:
float length(float);
float area(float);
private:
float r;
};
float yuan::length(float r)
{float len;
len=2*Pi*r;}
float yuan::area(floay r)
{float ar;
ar=Pi*r*r;}
void main()
{
yuan m;
cout<
}
#include
using namespace std;
class circle
{
public:circle(double r):a(r){}
void length(){cout<<"length="<<2*3.14*a<
int main()
{
circle x(10.0);
x.length();
x.area();
cin.get();
}
周长:(保留2位小数)
var
r,l:real;
begin
readln(r);
l:=2*3.14*r;
writeln(l:0:2);
end
面积:(保留2位小数)
var
r,s:real;
begin
readln(r);
s:=3.14*r*r;
writeln(s:0:2);
end.