三周4

第三周上机任务4

分类: 第二学期 90人阅读 评论(0) 收藏 举报
* 程序头部注释开始
* 程序的版权和版本声明部分
* Copyright (c) 2012, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称:lianxi.cpp
* 作 者 刘文英 
* 完成日期:2012 年 3 月 12日
* 版 本号:v3.3

* 对任务及求解方法的描述部分
* 输入描述:......
* 问题描述:......
* 程序输出:......
* 程序头部的注释结束

  1. #include <iostream>   
  2.   
  3. using namespace std;  
  4.   
  5. class chang  
  6. {  
  7.      public:  
  8.          void volume();  
  9.          void areas();  
  10.          void display();  
  11.      private:  
  12.          float length;  
  13.          float width;  
  14.          float heigth;  
  15.          float t;  
  16.          float b;  
  17. };  
  18.   
  19. chang s1,s2,s3;  
  20.   
  21. int main()  
  22. {  
  23.     s1.volume();  
  24.     s1.areas();  
  25.     s1.display();  
  26.     s2.volume();  
  27.     s2.areas();  
  28.     s2.display();  
  29.     s3.volume();  
  30.     s3.areas();  
  31.     s3.display();  
  32.   
  33.     return 0;  
  34. }  
  35.   
  36. void chang::volume()  
  37. {   
  38.         cout << "请输入长 宽 高" << endl;  
  39.   
  40.     cin>>length>>width>>heigth;  
  41.   
  42.     t=length*width*heigth;  
  43. }  
  44.   
  45. void chang::areas()  
  46. {  
  47.     b=length*width+width*heigth+length*heigth;  
  48. }  
  49.   
  50. void chang::display()  
  51. {  
  52.     cout <<"volume:"<<t<<endl<<"areas:"<<b<<endl;  
  53. }  
  1. 运行结果:  
  1. <img src="http://hi.csdn.net/attachment/201203/7/0_1331131800oIz0.gif" alt="" />  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值