【说明】 本程序的功能是根据矩形左上角和右下角顶点坐标生成一个矩形对象,然后输出该

题型:问答题

问题:

【说明】
本程序的功能是根据矩形左上角和右下角顶点坐标生成一个矩形对象,然后输出该矩形4个顶点的坐标,计算并输出该矩形的面积。
【C++代码】
#include<iostream>
using namespace std;
class MyPoint( //表示平面坐标系中的点的类
double x;
double y;
public:
MyPoint (double x,double y)this->x=x;this->y=y;
double getX()const (1) ;
double getY()const return y;
void show()const cout<<’(’<<x<<’,’<<y<<’)’;
;
class MyRectangle //表示矩形的类
MyPoint upleft;//矩形的左上角顶点
MyPoint down right; //矩形的右下角顶点
public:
MyRectangle(MyPoint upleft,MyPoint downright);
MyPoint getUpLeft()constreturn up_left; //返回左上角坐标
MyPoint getDownRight()constreturn down_right; //返回右下角坐标
MyPoint getUpRight()const;//返回右上角坐标
MyPoint getDownLeft()const; //返回左下角坐标
double area()const; //返回矩形的面积
;
MyRectangle:: MyRectangle( (2) ):
up left(p1),down_right(p2)
MyPoint MyRectangle::getUpRight()const

return MyPoint(down_right.getX(),up_left.getY());

MyPoint MyRectangle::getDownLeft()const

return MyPeint( (3) );

double (4) ::area()const

return (getUpLeft(),getX()-getDownRight().getX())*
(getDownRight().getY()-getUpLeft().getY());

int main( )

MyRectangle r(MyPoint(0,2),MyPoint(2,0));
r.getUpLeft(),show();
r.getUpRight().show();
r.getDown Right().show();
(5) ;
cout<<r.area()<<end1;
return 0;

考点:计算机软件水平考试初级程序员初级程序员下午试题
题型:问答题

Simon is wearing clothes from _____.

A.the 1980

B.1980s

C.the 1980s

D.1980s

题型:问答题

电机在选择时应根据负载的要求,尽量可能使电机运行在()值附近。

题型:问答题

在关系数据模型中,二维表的列称为  【10】  ,二维表的行称为元组。

题型:问答题

主治精神分裂症的药物

A.氯丙嗪
B.克林霉素
C.异丙肾上腺素
D.吗啡
E.氯琥珀胆碱

题型:问答题

硫化氢具有一种特殊的(),即使在其浓度较低时,也可以损伤人的嗅觉。

A.辛辣气味

B.臭鸡蛋气味

C.大蒜气味

D.不确定

更多题库