#include <iostream.h>
class Circle
{
public:
void calArea()
{
double r,area;
r=60.5;
area=3.14159*r*r;
cout<<"圆的半径为:"<<r<<endl;
cout<<"圆的面积为:"<<area<<endl;
}
};
void main()
{
Circle cobj;
cobj.calArea();
}
#include <iostream.h>
class circle
{
public:
void inputr()
{ cout<<"请输入圆的半径:"<<endl;
cin>>r;
}
void outpurarea()
{ cout<<"圆的面积为:"<<3.1415926*r*r<<endl;
}
private: float r;
};
main()
{
circle a;
a.inputr();
a.outpurarea();
}
#include <iostream.h>
main()
{
double r,area;
cout<<"请输入圆的半径:"<<endl;
cin>>r;
area=3.1415926*r*r;
cout<<"圆的面积为:"<<area<<endl;
}