#include <iostream>
using namespace std;
class Bulk
{
public:
Bulk(double l=1,double w=1,double h=1)
{
length=l;
width=w;
height=h;
}
void get_value();
void output();
private:
double length;
double width;
double height;
};
void Bulk::get_value()
{
double l,w,h;
cin>>l>>w>>h;
length=l;
width=w;
height=h;
}
void Bulk::output()
{
cout<<"长方柱体积"<<length*width*height<<"长方柱表面积"<<2*length*width+2*length*height+2*width*height<<endl;
}
int main()
{
int i;
Bulk b[5]={Bulk(2.3,4.5,6.7),Bulk(1.5,3.4),Bulk(10.5)};
b[4].get_value();
for(i=0;i<5;i++)
b[i].output();
}
长方柱类
最新推荐文章于 2023-03-06 15:04:19 发布