当前位置:   article > 正文

python编程求长方体体积_定义一个类,计算长方体的体积

输入长方体的边长a,b,c,求其体积。 python

#include &ltiostream&gt

using namespace std;

class box

{

private:

float length;

float width;

float height;

public:

box(float a,float b,float c);

void volume();

};

box::box(float a,float b,float c)

{

length=a;

width=b;

height=c;

}

void box::volume()

{

cout&lt&lt"长方体的体积是:"&lt&ltlength*width*height&lt&ltendl;

}

void main()

{

float a,b,c;

cout&lt&lt"请输入长方体的长:";

cin&gt&gta;

cout&lt&lt"请输入长方体的宽:";

cin&gt&gtb;

cout&lt&lt"请输入长方体的高:";

cin&gt&gtc;

box chang(a,b,c);

chang.volume();

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/833673
推荐阅读
相关标签
  

闽ICP备14008679号