长方柱类
来源:互联网 发布:网络大电影报批流程 编辑:程序博客网 时间:2024/05/18 10:16
#include <iostream>
using namespace std;
class Bulk
{
public:
Bulk(double l=1,double w=1,double h=1)
{
length=l;
width=w;
height=h;
}
void get_value();
void output();
private:
double length;
double width;
double height;
};
void Bulk::get_value()
{
double l,w,h;
cin>>l>>w>>h;
length=l;
width=w;
height=h;
}
void Bulk::output()
{
cout<<"长方柱体积"<<length*width*height<<"长方柱表面积"<<2*length*width+2*length*height+2*width*height<<endl;
}
int main()
{
int i;
Bulk b[5]={Bulk(2.3,4.5,6.7),Bulk(1.5,3.4),Bulk(10.5)};
b[4].get_value();
for(i=0;i<5;i++)
b[i].output();
}
using namespace std;
class Bulk
{
public:
Bulk(double l=1,double w=1,double h=1)
{
length=l;
width=w;
height=h;
}
void get_value();
void output();
private:
double length;
double width;
double height;
};
void Bulk::get_value()
{
double l,w,h;
cin>>l>>w>>h;
length=l;
width=w;
height=h;
}
void Bulk::output()
{
cout<<"长方柱体积"<<length*width*height<<"长方柱表面积"<<2*length*width+2*length*height+2*width*height<<endl;
}
int main()
{
int i;
Bulk b[5]={Bulk(2.3,4.5,6.7),Bulk(1.5,3.4),Bulk(10.5)};
b[4].get_value();
for(i=0;i<5;i++)
b[i].output();
}
0 0
- 长方柱类
- 类与长方柱
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- linux shell “(())” 双括号运算符使用
- 【系统使用】解决安卓USB共享网络给Windows10异常卡顿问题
- Emgucv_Motion_Detection_MotionHistory_Human_Activity_in_video
- mysql 查询 表连接详解
- 【笔记】Qt程序在Windows、OS X、CentOS、Ubuntu下的打包处理
- 长方柱类
- Picasso轻松实现圆角图片
- ChecjIO: Verify Anagrams
- java基础学习总结——public,private,protected,和默认的区别
- pyinstaller打包exe错误
- python核心编程学习笔记-2016-08-28-01-习题18-4和习题18-9
- chrome浏览器打开百度http出现红叉
- 指向学生类的指针
- 用javah导出类的头文件,Not a valid class name或者错误: 找不到 'HelloNDK' 的类文件