阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。【说明】本程序的功能是根据矩形左上角和右下角顶点坐标生成一个矩形对象,然后输出该矩形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()const{return up_left;} //返回左上角坐标MyPoint getDownRight()const{return 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;}

阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。

【说明】

本程序的功能是根据矩形左上角和右下角顶点坐标生成一个矩形对象,然后输出该矩形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()const{return up_left;} //返回左上角坐标

MyPoint getDownRight()const{return 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;

}


相关考题:

阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。【说明】以下程序为求行列式X(5,5)的值S。【Visual Basic代码】Private Function col ( byval x ( 5,5 ) as integer ) as longdim fesult as longdim temp as longdim I as integerdim j as integerdim k as imegerresult = 0for I = to 5(1)for j = 1 to 5if I+j>6 thenk= ( 1+j ) mod 5elsek=1endiftemp=temp*x ( k,j )(2)result=(3)(4)(5)End function

阅读以下说明和c++码,将应填入(n)处的字名写在的对应栏内。[说明] 以下函数完成求表达式的值,请填空使之完成此功能。float sum ( float x ){ float s=0.0;int sign = 1;(1);for(inti=1;(2); i+ +){t=t*x;s=s+(3);sign = - sign;(4);}

阅读下列说明和流程图,将应填入(n)处的语句写在对应栏内。【说明】下列流程图用泰勒(Taylor)展开式y=ex=1+x+x2/2!+x3/3!+…+xn/n!+…计算并打印ex的近似值,其中用ε(>0)表示误差要求。【流程图】

阅读以下说明,以及用C++在开发过程中所编写的程序代码,将应填入(n)处的字句写在对应栏内。【说明】在下面函数横线处填上适当的字句,使其输出结果为:构造函数.构造函数.1,25,6析构函数析构函数.【C++代码】include "iostream.h"class AA{ public;AA(int i,int j){A=i; B=j;cout<<"构造函数.\n";}~AA(){(1);}void print();private:int A, B;};void AA∷print(){cout<<A<<","<<B<<endl;}void main(){AA *a1, *a2;(2)=new AA(1, 2);a2=new AA(5, 6);(3);a2->print();(4) a1;(5) a2;}

阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。【说明】阅读下面几段C++程序回答相应问题。比较下面两段程序的优缺点。①for (i=0; i<N; i++ ){if (condition)//DoSomething…else//DoOtherthing…}②if (condition) {for (i =0; i<N; i++ )//DoSomething}else {for (i=0; i <N; i++ )//DoOtherthing…}

阅读以下应用说明、属性设置及Visual Basic程序代码,将应填入______处的语句写在答题纸的对应栏内。[应用说明7]本应用程序的运行窗口如图2-5所示。只要用户单击“闪烁”按钮,文字“欢迎光临”就会以0.3s消失、0.3s显示反复进行闪烁;单击“停止”按钮,闪烁停止,恢复图示的初态。[属性设置7][程序代码7]Private Sub CmdF C1ick()Timerl. (3)=TrueLabel.Visible=FalseEnd SubPrivate Sub Timerl_Timer()(4)=not Label.VisibleEnd SubPrivate Sub CmdT_Click()Timerl.Enabled=(5)Label.Vlsible=trueEnd Sub

试题三(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

()阅读下列说明和C语言程序,将应填入 (n)处的语句写在答题纸的对应栏内。[说明]下面程序是一个带参数的主函数,其功能是显示在命令行中输入的文本文件内容。[C语言函数]#include"stdio.h"main(argc,argv) int argc; char *argv[]; { (1) ; if((fp=fopen(argv[1],”r’’))== (2) ) { printf(”file not open!\n”);exit(0);} while( (3) ) putchar( (4) ); (5); }

阅读下列说明和C++-代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图5-1所示的类图。【C++代码】 #include using namespace std; class invoice{ public: (1){ cout

阅读下列说明和?C++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】阅读下列说明和?Java代码,将应填入?(n)?处的字句写在答题纸的对应栏内。【说明】某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种类可能不同,但其制作过程相同。前台服务员?(Waiter)?调度厨师制作套餐。现采用生成器?(Builder)?模式实现制作过程,得到如图?6-1?所示的类图。