您的位置:首页 > 编程语言 > C语言/C++

c++:chang fang zhu de tiji yu mianji

2016-06-14 22:50 513 查看
#include<iostream>

#include<cmath>

using namespace std;

class Bulk

{

  public:

        void getbulk()

        {

            int l,w,h;

            cout<<"请输入三个长方柱体的长宽高"<<endl;

            cin>>l>>w>>h;

            length=l;

            width=w;

            height=h;

        }

        void volume()

        {

            double v;

            v=length*width*height;

            cout<<"长方柱的体积为: "<<v<<endl;

        }

        void areas()

        {

            double s;

            s=2*length*height+2*length*width+2*height*width;

            cout<<"长方柱的总面积为: "<<s<<endl;

        }

  private:

        double length,width,height;

};

int main()

{

    Bulk a,b,c;

    a.getbulk();

    b.getbulk();

    c.getbulk();

    a.volume();

    b.volume();

    c.volume();

    a.areas();

    b.areas();

    c.areas();

    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: