第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; }
运行结果:
相关文章推荐
- android中View的工作原理(android内核学习记录)
- 第五周项目3(2)
- 大话设计模式—状态模式
- 合并模拟器和真机调试的静态库
- 初识ZooKeeper
- ADS1247寄存器中文翻译
- 第四周项目5-用递归方法求解(2)
- 田忌赛马
- centos最小安装之后,再安装图形界面
- ActiveMQ相关背景(转)
- iOS设计中 UI设计之沙盒与数据持久化
- 推荐几个js的好链接
- 学习笔记5
- java第三次作业
- 【BZOJ1041】[HAOI2008]圆上的整点【数学】
- JavaScritpt的DOM初探之Node(一)
- 归园田居 东晋 陶渊明 注音版
- CentOS6 Shell脚本/bin/bash^M: bad interpreter错误解决方法
- 单行函数
- UVA 11090 图论加二分