第五周作业 长方形

来源:互联网 发布:水淀粉挡子弹知乎 编辑:程序博客网 时间:2024/04/27 19:15

/*
 *copyright(c) 2014,烟台大学计算机学院
 *All rights reserved
 *文件名称:test.cpp
 *作者:谭泽纯
 *版本:v6.0
 *
 *问题描述:长方形

 *输入描述:无
 *程序输出:
*/

 

 

 


#include<iostream>
using namespace std;
class Bulk
{
private:
 int length;
 int width;
 int height;
public:
 Bulk(int l,int w,int h):length(l),width(w),height(h){}
 void set()
 {
  cin>>length>>width>>height;
 }
 int volume()
 {
  return length*width*height;
 }
 int areas()
 {
  return 2*(length*width+length*height+width*height);
 }
};
int main()
{
 Bulk a(1,2,3),b(4,5,6),c(7,8,9);
 a.set();
 b.set();
 c.set();
 cout<<a.volume()<<a.areas()<<endl;
 cout<<b.volume()<<b.areas()<<endl;
 cout<<c.volume()<<c.areas()<<endl;
}
0 0
原创粉丝点击