项目1(拓展)--矩形类
来源:互联网 发布:2345看图王 mac 编辑:程序博客网 时间:2024/04/30 01:45
/**程序的版权和版本声明部分:*Copyright(c)2013,烟台大学计算机学院学生*All rights reserved.*文件名称:*作者:尚振伟*完成日期:2014年3月24日*版本号:v0.1*对任务及求解方法的描述部分:*输入描述:无*问题描述:*程序输入:*程序输出:*问题分析:*算法设计:*我的程序:*/#include <iostream>#include <Cmath>using namespace std;class Rectangle{public: Rectangle(double,double); double area(); double perimeter(); double dx(); void issquare();private: double length; double width;};Rectangle::Rectangle(double l,double w){ length=l; width=w;}double Rectangle::area(){ return(length*width);}double Rectangle::perimeter(){ return(length+width);}double Rectangle::dx(){ double t; t=sqrt(length*length+width*width); return(t);}void Rectangle::issquare(){ if(length==width) { cout<<"此矩形是正方形"<<endl; } else { cout<<"此矩形不是正方形"<<endl; }}int main(){ Rectangle r(5,6); r.issquare(); cout<<"面积为:"<<r.area()<<endl; cout<<"周长为:"<<r.perimeter()<<endl; cout<<"对象线为:"<<r.dx()<<endl; return 0;}
结果展示:
心得体会:小试牛刀,初体验。
0 0
- 项目1(拓展)--矩形类
- 第五周项目1拓展矩形类
- 2014-03-25项目1——拓展矩形类
- 第五周项目一拓展:矩形类
- 5-1 矩形类(拓展)
- 矩形类拓展
- 第五周项目1(拓展)-矩形类的构造函数
- 第二学期第五周项目1--三角形类的构造函数拓展(矩形)
- 第五周 项目一 拓展4 自定义一个 矩形类
- 第五周项目1拓展 判断是否为矩形 求矩形面积
- 第五周项目一拓展矩形
- 第五周(项目一拓展)——矩形类的构造函数。
- 项目4--拓展1
- 项目1--拓展
- 第五周 项目1 扩展 矩形类
- 第十周项目1拓展
- 第十周项目1拓展
- 第五周上机实践项目——三角形拓展之矩形
- Android4.1 屏蔽一些不用的apk桌面显示
- Hadoop NullPointerException
- 【Leetcode】Roman to Integer
- 正确使用Block避免Cycle Retain和Crash
- SlidingMenu属性详解
- 项目1(拓展)--矩形类
- 安装samba,出现perl(Convert::ASN1) is needed by samba……问题的解决方法
- 第五周项目一三角形类1
- android 在onCreate中获取空间宽高
- Redhat Linux telnet服务安装配置
- lighttpd 访问php 403 forbidden解决方案
- 教你透彻了解红黑树
- Bluetooth蓝牙设备配对 - 常见问题解答
- 蓝桥杯软件大赛题目集锦之编程大题