3个回答
展开全部
//类内实现
#include<iostream>
using namespace std;
class Circle
{
private:
double radius;
public:
Circle() { radius=0; }
Circle(double r) { radius=r; }
double GetRadius() { return radius; }
void setRadius(int r) { radius=r; }
double GetDiameter() { return 2*radius; }
double GetPerimeter() { return 6.28*radius; }
double GetArea() { return 3.14*radius*radius; }
};
int main()
{
Circle c;
int r;
cout<<"请输入圆的半径:";
cin>>r;
c.setRadius(r);
cout<<"半径为"<<c.GetRadius();
cout<<"的圆的直径为:"<<c.GetDiameter();
cout<<",周长为:"<<c.GetPerimeter();
cout<<",面积为:"<<c.GetArea()<<endl;
return 0;
}
//类外实现
#include<iostream>
using namespace std;
class Circle
{
private:
double radius;
public:
Circle();
Circle(double r);
double GetRadius();
void setRadius(int r);
double GetDiameter();
double GetPerimeter();
double GetArea();
};
Circle::Circle() { radius=0; }
Circle::Circle(double r) { radius=r; }
double Circle::GetRadius() { return radius; }
void Circle::setRadius(int r) { radius=r; }
double Circle::GetDiameter() { return 2*radius; }
double Circle::GetPerimeter() { return 6.28*radius; }
double Circle::GetArea() { return 3.14*radius*radius; }
int main()
{
Circle c;
int r;
cout<<"请输入圆的半径:";
cin>>r;
c.setRadius(r);
cout<<"半径为"<<c.GetRadius();
cout<<"的圆的直径为:"<<c.GetDiameter();
cout<<",周长为:"<<c.GetPerimeter();
cout<<",面积为:"<<c.GetArea()<<endl;
return 0;
}
#include<iostream>
using namespace std;
class Circle
{
private:
double radius;
public:
Circle() { radius=0; }
Circle(double r) { radius=r; }
double GetRadius() { return radius; }
void setRadius(int r) { radius=r; }
double GetDiameter() { return 2*radius; }
double GetPerimeter() { return 6.28*radius; }
double GetArea() { return 3.14*radius*radius; }
};
int main()
{
Circle c;
int r;
cout<<"请输入圆的半径:";
cin>>r;
c.setRadius(r);
cout<<"半径为"<<c.GetRadius();
cout<<"的圆的直径为:"<<c.GetDiameter();
cout<<",周长为:"<<c.GetPerimeter();
cout<<",面积为:"<<c.GetArea()<<endl;
return 0;
}
//类外实现
#include<iostream>
using namespace std;
class Circle
{
private:
double radius;
public:
Circle();
Circle(double r);
double GetRadius();
void setRadius(int r);
double GetDiameter();
double GetPerimeter();
double GetArea();
};
Circle::Circle() { radius=0; }
Circle::Circle(double r) { radius=r; }
double Circle::GetRadius() { return radius; }
void Circle::setRadius(int r) { radius=r; }
double Circle::GetDiameter() { return 2*radius; }
double Circle::GetPerimeter() { return 6.28*radius; }
double Circle::GetArea() { return 3.14*radius*radius; }
int main()
{
Circle c;
int r;
cout<<"请输入圆的半径:";
cin>>r;
c.setRadius(r);
cout<<"半径为"<<c.GetRadius();
cout<<"的圆的直径为:"<<c.GetDiameter();
cout<<",周长为:"<<c.GetPerimeter();
cout<<",面积为:"<<c.GetArea()<<endl;
return 0;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
唉,我是数学渣,复数不会
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询