其他分享
首页 > 其他分享> > 自考新教材-p90_5(4)

自考新教材-p90_5(4)

作者:互联网

源程序:

#include <iostream>
#define PI 3.1415926
using namespace std;

class Cylinder
{
private:
double r, h;
public:
Cylinder(double rr, double hh)
{
r = rr;
h = hh;
}
double circle_length()
{
return 2 * PI*r;
}
double circle_area()
{
return PI*r*r;
}
double Cylin_tiji();
};

double Cylinder::Cylin_tiji()
{
return circle_area()*h;
}

int main()
{
double radius, height;
cout << "请输入圆柱的底面半径和高:";
cin >> radius >> height;
Cylinder C(radius, height);
cout << "圆柱体的底面周长为:" << C.circle_length() << endl;
cout << "圆柱体的底面积为:" << C.circle_area() << endl;
cout << "圆柱体的体积为:" << C.Cylin_tiji() << endl;
system("pause");
return 1;
}

运行结果:

 

标签:Cylinder,return,cout,新教材,double,height,p90,radius,自考
来源: https://www.cnblogs.com/duanqibo/p/12269879.html