Problem G 平面上的点和线——Point类、Line类 (IV).docx_第1页
Problem G 平面上的点和线——Point类、Line类 (IV).docx_第2页
Problem G 平面上的点和线——Point类、Line类 (IV).docx_第3页
Problem G 平面上的点和线——Point类、Line类 (IV).docx_第4页
Problem G 平面上的点和线——Point类、Line类 (IV).docx_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Problem G 平面上的点和线Point类、Line类 (IV)Time Limit:1 SecMemory Limit:128 MBSubmit:2620Solved:1677SubmitStatusWeb BoardDescription在数学上,平面直角坐标系上的点用X轴和Y轴上的两个坐标值唯一确定,两点确定一条线段。现在我们封装一个“Point类”和“Line类”来实现平面上的点的操作。根据“append.cc”,完成Point类和Line类的构造方法和show()方法,输出各Line对象和Point对象的构造和析构次序。接口描述:Point:show()方法:按格式输出Point对象。Line:show()方法:按格式输出Line对象。Input输入的第一行为N,表示后面有N行测试样例。每行为两组坐标“x,y”,分别表示线段起点和终点的x坐标和y坐标,两组坐标间用一个空格分开,x和y的值都在double数据范围内。Output输出为多行,每行为一条线段,起点坐标在前终点坐标在后,每个点的X坐标在前,Y坐标在后,Y坐标前面多输出一个空格,用括号包裹起来。输出格式见sample。C语言的输入输出被禁用。Sample Input40,0 1,11,1 2,32,3 4,50,1 1,0Sample OutputPoint : (1, -2) is created.Point : (2, -1) is created.Point : (0, 0) is created.Point : (0, 0)Point : (0, 0) is created.Point : (0, 0) is created.Line : (0, 0) to (0, 0) is created.Point : (0, 0) is created.Point : (0, 0) is created.Line : (0, 0) to (0, 0) is created.Point : (0, 0) is created.Point : (0, 0) is created.Line : (0, 0) to (0, 0) is created.Point : (0, 0) is created.Point : (0, 0) is created.Line : (0, 0) to (0, 0) is created.=Line : (0, 0) to (1, 1)=Line : (1, 1) to (2, 3)=Line : (2, 3) to (4, 5)=Line : (0, 1) to (1, 0)=Point : (1, -2) is copied.Point : (2, -1) is copied.Line : (1, -2) to (2, -1) is created.Point : (1, -2) is copied.Point : (0, 0) is copied.Line : (1, -2) to (0, 0) is created.Point : (2, -1) is copied.Point : (0, 0) is copied.Line : (2, -1) to (0, 0) is created.Point : (0, 0) is copied.Point : (2, -1) is copied.Line : (0, 0) to (2, -1) is created.Line : (1, -2) to (2, -1)Line : (1, -2) to (0, 0)Line : (2, -1) to (0, 0)Line : (0, 0) to (2, -1)Line : (0, 0) to (2, -1) is erased.Point : (2, -1) is erased.Point : (0, 0) is erased.Line : (2, -1) to (0, 0) is erased.Point : (0, 0) is erased.Point : (2, -1) is erased.Line : (1, -2) to (0, 0) is erased.Point : (0, 0) is erased.Point : (1, -2) is erased.Line : (1, -2) to (2, -1) is erased.Point : (2, -1) is erased.Point : (1, -2) is erased.Line : (2, 3) to (4, 5) is erased.Point : (4, 5) is erased.Point : (2, 3) is erased.Line : (1, 1) to (2, 3) is erased.Point : (2, 3) is erased.Point : (1, 1) is erased.Line : (0, 0) to (1, 1) is erased.Point : (1, 1) is erased.Point : (0, 0) is erased.Line : (0, 0) to (0, 0) is erased.Point : (0, 0) is erased.Point : (0, 0) is erased.Point : (0, 0) is erased.Point : (2, -1) is erased.Point : (1, -2) is erased.HINTAppend Code#include#includeusing namespace std;class Pointdouble ax,ay;public:friend class Line;Point(Point &a)ax=a.ax;ay=a.ay;coutPoint : (ax, ay) is copied.endl;Point(double x=0,double y=0):ax(x),ay(y)coutPoint : (ax, ay) is created.endl;/Point():ax(0),ay(0)Point()coutPoint : (ax, ay) is erased.endl;void show()coutPoint : (ax, ay)endl;class LinePoint p,q;public:Line():p(0,0),q(0,0)coutLine : (p.ax, p.ay) to (q.ax, q.ay) is created.endl;Line(Point &a,Point &b):p(a),q(b)coutLine : (p.ax, p.ay) to (q.ax, q.ay) is created.endl;Line(double x1,double y1,double x2,double y2):p(x1,y1),q(x2,y2)coutLine : (p.ax, p.ay) to (q.ax, q.ay) is created.endl;Line()coutLine : (p.ax, p.ay) to (q.ax, q.ay) is erased.endl;void SetLine(double x1, double y1, double x2, double y2)p.ax=x1;p.ay=y1;q.ax=x2;q.ay=y2;void show()coutLine : (p.ax, p.ay) to (q.ax, q.ay)num;Line linenum;for(i = 1; i

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论