第三周上机任务4
* 程序头部注释开始
* 程序的版权和版本声明部分
* Copyright (c) 2012, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:lianxi.cpp
* 作
者 刘文英
* 完成日期:2012 年 3 月 12日
* 版 本号:v3.3
* 程序的版权和版本声明部分
* Copyright (c) 2012, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:lianxi.cpp
* 作
* 完成日期:2012 年 3 月 12日
* 版 本号:v3.3
* 对任务及求解方法的描述部分
* 输入描述:......
* 问题描述:......
* 程序输出:......
* 程序头部的注释结束
- #include <iostream>
- using namespace std;
- class chang
- {
- public:
- void volume();
- void areas();
- void display();
- private:
- float length;
- float width;
- float heigth;
- float t;
- float b;
- };
- chang s1,s2,s3;
- int main()
- {
- s1.volume();
- s1.areas();
- s1.display();
- s2.volume();
- s2.areas();
- s2.display();
- s3.volume();
- s3.areas();
- s3.display();
- return 0;
- }
- void chang::volume()
- {
- cout << "请输入长 宽 高" << endl;
- cin>>length>>width>>heigth;
- t=length*width*heigth;
- }
- void chang::areas()
- {
- b=length*width+width*heigth+length*heigth;
- }
- void chang::display()
- {
- cout <<"volume:"<<t<<endl<<"areas:"<<b<<endl;
- }
- 运行结果:
- <img src="http://hi.youkuaiyun.com/attachment/201203/7/0_1331131800oIz0.gif" alt="" />