当前位置: > c++需要求3个长方柱体积...
题目
c++需要求3个长方柱体积

提问时间:2020-12-10

答案
#include <iostream>
using namespace std;
class cube
{
public:
    void set();//构造函数
    float com_volume();//计算体积
    void disp();//输出体积
private:
    float length;
    float width;
    float height;
};
void cube::set()
{
    float l, w, h;
    cout<<"下面进入长方柱的参数设置,单位:立方米"<<endl;
    cout<<"请输入长方柱的长:";
    cin>>l;
    length=l;
    cout<<"请输入长方柱的宽:";
    cin>>w;
    width=w;
    cout<<"请输入长方柱的高:";
    cin>>h;
    height=h;
}
float cube::com_volume()
{
    return length*width*height;
}
void cube::disp()
{
    cout<<"此长方柱的体积为:"<<com_volume()<<"立方米"<<endl;
}
int main()
{
    cube c[3];
    for(int i=0; i<3; i++)
    {
        c[i].set() ;
        c[i].disp();
        cout<<endl;
    }
    return 0;
}
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.