长方柱
来源:互联网 发布:mysql 怎么查询密码 编辑:程序博客网 时间:2024/04/27 14:31
#include <iostream> #include <cmath> using namespace std; class Volume { public: void setdata(double length,double width,double height); double area(); double volume(); private: double length; double width; double height; }; //下面定义需要的成员函数 void Volume::setdata(double l,double w,double h)//赋值 { length=l; width=w; height=h; } double Volume::area()//求面积 { return 2*(length*width+width*height+height*length); } double Volume::volume()//求体积 { return length*width*height; } int main() { int t=3,i=1; while(t--) { double l,w,h; cout<<"请输入长方柱"<<i<<"的长: "; cin>>l; cout<<"请输入长方柱"<<i<<"的宽: "; cin>>w; cout<<"请输入长方柱"<<i<<"的高: "; cin>>h; Volume v; v.setdata(l,w,h); cout<<"长方柱"<<i<<"的表面积为: "<<v.area()<<endl; cout<<"长方柱"<<i<<"的体积为: "<<v.volume()<<endl; i++; } return 0; }
0 0
- 长方柱
- 长方柱
- 长方柱
- 长方柱
- 长方柱
- 长方柱类
- 类与长方柱
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 长方柱类
- 第一周项目四
- LeetCode OJ Word Ladder
- DBMS_JOB
- stagefright + omx小结
- LeetCode OJ Sort Colors
- 长方柱
- 算法导论 第22章 图的基本算法(一)
- LeetCode OJ Length of Last Word
- c# 调 用c语言动态库 ref string 方式
- Hadoop
- 第二周项目3-时间类
- Ubuntu 下安装mysql
- LeetCode OJ Divide Two Integers
- MongoDB安装及介绍