您的位置:首页 > 其它

第5周-项目4-长方柱类

2016-03-28 20:27 281 查看
问题及代码:

/*
*Copyright (c)2016,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:main.cpp
*作    者:王艺霖
*完成日期:2016年3月28日
*版 本 号:v1.0
*问题描述: 求3个长方柱的体积,表面积。
*/
#include <iostream>
using namespace std;
class Bulk
{
public:
void set();
void get();
void qiu();
private:
int length;
int width;
int height;
int volume;
int areas;
};
void Bulk::set()
{
cin>>length>>width>>height;
}
void Bulk::qiu()
{
volume = length*width*height;
areas = length*width*2 + 2*width*height + length*2*height;

}
void Bulk::get()
{
cout << "体积:" << volume << endl;
cout << "表面积:" << areas << endl;

}
int main()
{

Bulk B1,B2,B3;
B1.set();
B2.set();
B3.set();

B1.qiu();
B2.qiu();
B3.qiu();

B1.get();
B2.get();
B3.get();

return 0;
}


运行结果:

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