发布网友 发布时间:2023-08-22 01:07
共0个回答
public Circle() { this(1);} public Circle(double r) { radius = r;} public double area() { return Math.PI * radius * radius;} public double circumference() { return 2 * Math.PI * radius;} public double getRadius() { return radius;} public void setRadius(double radius...
定义一个圆形类Circle,该类有三个double型的私有数据成员x,y和radius...void Circle::operator +(double n){ x=x+n;y=y+n;radius=radius+n;} ostream & operator <<(ostream &out, Circle &C){ out<<"圆心:"<<C.x<<","<<C.y<<" 半径:"<<C.radius<<endl;return out;} int main(){ double x,y,r,n;cin>>x>>y>>r>>n;Circle c1(x,y,r...
完成一个名为circle的圆类,其数据成员int*radius为指向其半径的指针...include#includeusingnamespacestd;classCircle{doubler,Area,Circumference;public:Circle(doublea=0);Circle(Circle&);voidSetR(doubleR);doubleGetR(){returnr;}doubleGetAreaCircle(){returnArea;}doubleGetCircumference(){returnCircumference;}};Circle::Circle(doublea){r=a;Area=r*r*3.14159265;Ci...
设计一个圆类Circle,具有属性:圆心坐标x和y及圆半径r,除具有设置及获取...圆心坐标为:("+getX()+","+getY()+")\n半径:"+getR()+"\n高:"+h);}}CylinderTest类:public class CylinderTest {public static void main(String[] args) {Cylinder c=new Cylinder();c.printAllAttribute();System.out.println("表面积为:"+c.area());System.out.println("体积...
C#编程题。期末考试题。创建一个Circle类,有数据成员表示圆的半径,其中...} } public class Circle { public Circle(double radius) { Radius = radius; } public double Radius; public double GetPerimeter() { return 2 * Math.PI * Radius; } public double GetArea() { return Math.PI * Math.Pow(Radius, 2); ...
java编程:定义一个圆类,属性为半径,方法为对输入的半径计算其周长和面...r;public double getR() {return r;}public void setR(double r) {this.r = r;}public Test(double r) {super();this.r = r;}public void MJ(){System.out.println("圆的面积为:" + (3.14 * this.getR() * this.getR()));}public void ZC(){System.out.println("圆的周长...
实现一个名为Circle的简单圆类。 数据成员int *itsRadius为一个指向其...}void Circle::SetRadius(int r){*itsRadius = r;}double Circle::GetArea(){return PI * (*itsRadius) * (*itsRadius);}void Circle::Output(){cout<<"圆半径:"<<*itsRadius<<endl;cout<<"圆面积:"<<GetArea()<<endl;}int main(){Circle c1;Circle c2 = c1;c1.SetRadius(1);...
...2、 自定义一个circle对象,其属性r为圆的半径,方法Area的作用是求...function circle(r){ this.r=r this.Area=Area this.Circum=Circum } function Circum(){ return(3.14*2*this.r)} function Area(){ return(3.14*this.r*this.r)} r=parseInt(prompt("请输入半径:",""));var newcircle=new circle(r)var Circumcapital=newcircle.Circum var Area...
c#定义一个类圆Circle或者定义一个矩形类Rectangle,分别计算它们的周长...public class Circle : shape { public int r;public double s, l;public void GetArea(int r){ s = r * r * PI;Console.WriteLine("圆形的面积是:{0}", s);} public void GetPerim(int r){ l = 2 * r * PI;Console.WriteLine("圆形的面积是:{0}", l);} } class Program ...
实现一个名为SimpleCircle的简单圆类,其数据成员int *itsRadius为一个...class SimpleCircle {private:int *itsRadius;public:SimpleCircle(int Radius=0){ if(Radius<=0)itsRadius=0;else itsRadius=Radius;}float getPerimeter()//获得周长 { return 2*PI*(*itsRadius);}float getArea(){ return PI*(*itsRadius)*(*itsRadius);}int getRadius(){return *itsRadius...