




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2025学年新教材高中历史 第九单元 当代世界发展的特点与主要趋势 第23课 和平发展合作共赢的时代潮流(1)说课稿 新人教版必修《中外历史纲要(下)》
- 3.2 代数式的值说课稿-2025-2026学年初中数学华东师大版2012七年级上册-华东师大版2012
- 奇怪的花瓶黏土课件
- 福建成人高考考试题库及答案
- 民政局定制离婚协议书样本及权益保障指南
- 钢结构工程安全施工合同
- 消防安全检测与维保及消防系统改造升级合同
- 企业员工创新项目启动资金借款合同模板
- 担保人责任明确的带担保贷款合同
- 高新技术研发项目合同招标主管任职要求及职责
- 安全经验分享食物中毒
- 四年级上册数学教案 -平行与垂直 人教版
- 2022年工程机械行业发展现状分析
- 《函数的奇偶性》教学课件与导学案
- DB11-T 1796-2020文物建筑三维信息采集技术规程
- (完整版)工程流体力学课件(第四版)
- RCEP的机遇与挑战研究报告
- 非常规油气勘探开发
- 小学科学课堂存在的问题与解决方法
- 陕西污水处理定价成本监审办法
- 公司级安全技术交底内容
评论
0/150
提交评论