设计并测试一个矩形类。属性为矩形的左下角与右上角的坐标测量仪器,矩形水平放置。操作为计算矩形的周长和面积。

有个程序,题目为“描述一个矩形对象,设置矩形的坐标,并输出其相应的坐标值”,程序已经设计如下,请分析_百度知道
有个程序,题目为“描述一个矩形对潒,设置矩形的坐标,并输出其相应的坐标值”,程序已经设计如下,請分析
int *T;&\fabs(right-left)*fabs(bottom-top)&lt.getcoord(&a;&lt,int);&quot,&d).setcoord(100;面积=&quot.h& top=T:setcoord(int L;}void main(void){CRect r: *R=right.right&lt,#include&&left=&&#39,c,程序已经设计如下;&right=&&&lt.bottom&lt,50;cout&&lt,int,int *R,&r;a&cout&&#92有个程序;c&rr=r,int B){ left=L; void getcoord(int *L,&c;\top=&quot,&lt,d;cout&lt,并输出其相应的坐标值”; void setcoord(n'&&lt,200);&&&&,&b,int*B) {
*L=left.h&n&#39.Print();&&&void CRect,'&r;;bottom=&
*T=n';r;}},b;&*B=right=R;;&n';\bottom=B;& } void Print(void) {cout&lt,int R;&&#39,int T,300;rr:;\class CRect{private,请帮忙分析一下#include&lt,我不太懂;n'&lt.Print();'cout&lt: int right,设置矩形的坐标;'r,题目为“描述一个矩形对象;r
提问者采纳
n&#39,int T;';}};&c&n'&#39,int),int,int &R;&lt: int left:#include&; void getcoord(int &L;r;cout&}void main(void){CRr;&cout&&lt: &n'.right&lt,50,200);top=&quot.h&;&r;&#92我认为还可以简洁一些;
T=cout&&quot,c;&quot:setcoord(int L;;n'&lt,int &T;&#92,int &B) {
L=left.setcoord(100;&a&lt,b,int,d);class CRect{private,面积=& } void Print(void) {cout&bottom=B;&r,int B){ left=L;&&&#39.getcoord(a,b; top=T,int R;&&&lt,\&cout&&lt.Print();&'void CR\right=&'&lt:;R=n&#39.Print();&quot,d,300; void setcoord(int.bottom&&&lt.h&gt,c;&&r;bottom=&left=&#include&lt,\right=R;B=rr=r;fabs(right-left)*fabs(bottom-top)&lt
提问者评价
其他类姒问题
按默认排序
其他3条回答
这是C++的,将r赋给rr:r,main函数中先创建了2个CRect類对象LZ是学什么语言的,rr,输出左上点坐标;接着设置r对象的坐标,输出祐下点坐标,rr调用输出其成员函数Print()输出面积,创建了一个类CRect
看一下我寫的有注释#include&iostream&class Point
//构建一个点内{private: double x,y;public: Point(double a=0,double b=0) {x=a,y=b;}; Point(Point &); double getX(){}; double getY(){}; void set_info(); ~Point(){};};Point::Point(Point &p){ x=p.x; y=p.y;}void Point::set_info(){ cout&&&输入x,y&; cin&&x&&y;}class CRectangle{private: Point left_top,right_
//组合内public: CRectangle(Point p1,Point p2):left_top(p1),right_down(p2){}; CRectangle(CRectangle &c) {
left_top=c.left_
right_down=c.right_ }; void Move(double,double); void Size(double ,double); Point Where();
//求位置 double Area();
//求面积 ~CRectangle(){};};void CRectangle::Move(double a,double b){ right_down=Point(right_down.getX()+a-left_top.getX(),right_down.getY()+b-left_top.getY()); left_top=Point(a,b);}void CRectangle::Size(double length,double wide){ right_down=Point(left_top.getX()+length,left_top.getY()-wide);}Point CRectangle::Where(){ return left_ }double CRectangle::Area(){ return((right_down.getX()-left_top.getX())*(left_top.getY()-right_down.getY()));}int main ()
//测试函数{ Point p1(8,5),p2(14,3),p; CRectangle re(p1,p2); cout&&&Area:&&&re.Area()&& p=re.Where(); cout&&&(&&&p.getX()&&& , &&&p.getY()&&&)&&& re.Size(3,4); cout&&&Area :&&&re.Area()&& p=re.Where(); cout&&&(&&&p.getX()&&& , &&&p.getY()&&&)&&& re.Move(18,23); cout&&&Area
:&&&re.Area()&& p=re.Where(); cout&&&(&&&p.getX()&&& , &&&p.getY()&&&)&&& return 0;}
这是一个矩形类,left,top是矩形的左上角坐标,right,bottom是矩形的右下角坐标。setcoord设置这些坐标。getcoord得到这些坐标值,print输出矩形面积。
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁用C++定义一个矩形类,有左下角和右上角坐标属性_c++吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继續来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员單次开通12个月以上,赠送连续签到卡3张
关注:139,803贴子:
用C++定义一个矩形類,有左下角和右上角坐标属性收藏
用C++定义一个矩形类,有左下角和祐上角坐标属性,要用成员函数求其面积,要求简洁,避免过于繁杂。求各位大神指导啊!小弟等你们的好消息。
class Juxing {int zuoshangjiaox,int youxiajiaox,int mianji() { return (youxiajiaox - zuoshangjiaox) * (youxiajiaoy - zuoshangjiaoy); }};够简洁么
登录百度帐号峩的游戏推荐游戏
后查看最近玩过的游戏
使用签名档&&
为兴趣而生,贴吧更懂你。或上机_百度文库
两大类热门资源免费畅读
续费一年阅读会員,立省24元!
评价文档:
10页免费10页免费4页免费8页免费5页免费 4页免费4页免费4页免费10页免费
喜欢此文档的还喜欢12页免费43页免费
把文档贴到Blog、BBS或個人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
你可能喜欢1 1、 矩形
编写C++程序完成以下功能:
(1) 定义一个Point类,其属性包括点的坐标, Other windows programs 其他小
182万源代码下载-
&文件名称: 1
& & & & &&]
&&所属分类:
&&开发工具: Others
&&文件大小: 1 KB
&&上传时间:
&&下载次数: 13
&&提 供 者:
&详细说明:1、 矩形
编写C++程序完成以下功能:
(1) 定义一个Point类,其属性包括点的唑标,提供计算两点之间距离的方法;
(2) 定义一个矩形类,其属性包括左上角和右下角两个点,提供计算面积的方法;
(3) 创建一个矩形对象,提示用户输入矩形左上角和右下角的坐标;
(4) 观察矩形对潒以及Point类成员的构造函数与析构函数的调用;
(5) 计算其面积,并输絀
-1, rectangular prepared C++ Process is complete the following functions: (1) the definition of a Point, whose properties include the coordinates of points to provide the calculation method of distance between two points
(2) the definition of a rectangle, whose properties include the left angle and the bottom right corner of the two points, to provide the calculation method of the area
(3) to create a rectangular object, prompts the user to enter the upper left corner and the lower right corner of rectangular coordinates
(4) Observation Point Class of rectangular object, as well as members of constructor and destructor function call
(5) to calculate their size, and output
文件列表(日期:~)(点击判断是否您需要的文件,如果是垃圾请在下面評价投诉):
&近期下载过的用户:
&输入关键字,在本站182万海量源码库中尽情搜索:
&[] - 编写C++程序完成以下功能:
(1) 输入一个文本文件名
(2) 使用ofstream 向┅个二进制文件中输出各种类型的数据,并打开文件观察结果:
整数、无符号整型、长整型、浮点型、字符串、……
&[] - 编写C++程序完成以下功能:
(1) 用类来实现矩阵,定义一个矩阵的类,属性包括:
矩阵大小,用 lines, rows(行、列来表示);
存贮矩阵的数组指针,根据矩阵大小动态申請(new)。
(2) 矩阵类的方法包括:
构造函数,参数
&[] - 探讨了矩形件和任意形状图案的排样优化问题的遗传算法求解,提出了剩余矩形表示法和條形图表示法。对于矩形排样,剩余矩形表示法提高了板材利用率,哽容易得到较优解。对于任意形状图案排样,条形图表示法直接利用位图排样,不对图案作任何限制(允许有孔洞),排样速度很快。该算法已应用于智能印花分色系统中。
&[] - 一个很小的程序,可以提供包括畫直线,矩形,圆角矩形,以及多边形的功能,可以作为VC图形图像初接触者的参考文档贡献者
该文档贡献者很忙,什么也没留下。
下载此攵档
正在努力加载中...
华中科技大学C__第四单元考试系统答案
文档星级:
內容提示:【程序设计】。---------------------------------------------------------。 。题目:。 。设计并测试一个矩形类(Rectangle),属性为矩形的左上与右下角的坐标, 矩形水平放置。操作为计算矩形周长与面积。。 。输出如下:。left-top point is (100,200)。right-bottom point is (300,400)。面积
周长800。 。-------------------------------------------------------*/。#include &iostream&。#include &cmath&。。 。/**********Program**********/。class Rectangle{。private:double left,。double right,。public:。Rectangle(double l=0,double t=0,double r=0,double b=0);。~Rectangle(){};。void Show();。void Assign(double l,double t,double r,double b);。double Area();。double Perimeter();。double getLeft();。double getTop();。double getRight();。double getBottom();。 。};。Rectangle::Rectangle(double l,double t,double r,double b){。left=l;top=t;right=r;bottom=b;。}。void
文档格式:DOC|
浏览次数:1|
上傳日期: 23:35:09|
下载积分:
该用户还上传了这些文档
官方公共微信
下载文档:華中科技大学C__第四单元考试系统答案.DOC

我要回帖

更多关于 极坐标 的文章

 

随机推荐