问题 问答题

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

答案

参考答案:(1)return x
(2)MyPoint p1,MyPoint p2
(3)up_left.getX(),down_right.getY()
(4)MyRectangle
(5)r.getDownLeft().show()

解析:

[分析]:
本题考查C++语言的基本语法结构和计算矩形面积。
题目要求根据矩形左上角和右下角顶点(已知)坐标生成一个矩形对象,然后输出该矩形4个顶点的坐标,计算并输出该矩形的面积。要计算矩形的面积,首先应该求出其长和宽。其长等于矩形的右上角顶点的x坐标减去矩形的左上角顶点的x坐标;其宽等于矩形的右上角顶点的y坐标减去矩形的右下角顶点的y坐标。
程序中定义了一个表示平面坐标系中点的类MyPoint来实现对矩形的操作,在其中定义了两个成员变量和一些公有的成员方法。第(1)空在这个类的getX()方法中,结合整个程序来看,此方法应该是用来获得平面中一点的x坐标,从紧接着的下一个函数,我们也很容易判断出这个函数的作用,因此,此空答案为return x。
程序中又定义了一个表示矩形的类MyRectangle来实现对矩形的操作,在这个类中定义了很多对矩形进行各种操作的方法。第(2)空在其构造函数MyRectangle()中,是构造函数的参数,根据构造函数声明可以知道,其两个是MyPoint类型的两个点,结合其函数下面的语句可以知道,这两个点分别是p1和p2,因此,此空答案为MyPointp1,MyPointp2。
在知道矩形的左上角顶点和右—下角顶点后,那么矩形的左下角顶点x坐标就等于左上角顶点的x坐标,y坐标就等于右下角顶点的y坐标。第(3)空在方法getDownLeft()下面,此方法的作用是求出矩形左下角顶点坐标并返回,它是通过调用类MyPoint的构造函数来实现的,而类MyPoint的构造函数的两个参数是平面坐标系中点的x和y坐标。因此,此空答案为up_left.getX(),down_right.getY()。
根据代码中的内容我们可以知道,第(4)空所在的函数是实现求矩形的面积。而根据类MyRectangle中函数的声明,用来求面积的函数是它的成员函数,而 MyRectangle::area()则表示函数area()是类MyRectangle中的成员函数。因此,此空答案为MyRectangle。
第(5)空在主函数里面,在主函数里面生成了一个矩形对象r,并给出了这个对象的左上角顶点和右下角顶点坐标。根据题目要求,最后要输出各顶点的坐标值和这个矩形的面积,而程序中已经输出了除左下角顶点外的其他顶点的坐标值,因此,此空要用来输出左下角顶点的坐标值,程序中能用来输出的函数是show(),即此空答案为 r.getDownLeft().show()。

完形填空
Today I am known for my voice. Perhaps the greatest honor came when I was asked to read The New Testament(《新约全书》)on tape .
But it  21  a long time to believe such good things could happen to me. When I was a child, I stuttered(结巴)so badly that I was completely  22  to speak in public.
 23  when I was 14, Professor Donald Crouch came to my school. He was a retired college professor. English was his favorite subject and  24  was his deepest love. He held a book of poems as if it were a crystal,  25  pages as if uncovering treasures. When he heard that our school was teaching Shakespeare and other classics, he felt  26  for not being a part of our school sooner.
When he  27  that I not only loved poetry but was  28  it, we became closer. There was, however, one  29 -- Professor Crouch could not stand the  30  that I refused to read my poems to the class.
“Jim, poetry is  31  to be read aloud,” he said. “You should be able to speak those beautiful words.” I shook my head and  32 .
One day he   33  me .
After handing in a poem, I waited for his  34 . It didn’t come. Instead one day as the students had gathered together, he  35  me , “Jim, I don’t think you wrote this poem.”
I stared at him in disbelief. “Why,” I started,  36  flooding me. “of course I did !” “Well, then,” he said, “you’ve got to prove it by getting up and reciting it from  37 .”
By then the other students had settled at their desks. With knees shaking, I walked up to the front. For a moment I stood there  38  Then I began, and kept going. I recited my poem all the way   39 !
Afterwards, Professor Crouch encouraged me to read other writers’ poetry before the public. I discovered I did have a(n)  40  and found my classmates actually looked forward to hearing me recite.
小题1:
A.lastedB.tookC.spentD.wasted
小题2:
A.impatientB.disabledC.unableD.impossible
小题3:
A.ButB.ThenC.BesidesD.However
小题4:
A.archaeologyB.artC.architectureD.poetry
小题5:
A.drawingB.turningC.writingD.finding
小题6:
A.regretfulB.thankfulC.relievedD.annoyed
小题7:
A.decidedB.recognizedC.learnedD.proved
小题8:
A.readingB.recitingC.publishingD.writing
小题9:
A.problemB.promiseC.agreementD.difference
小题10:
A.matterB.factC.ideaD.belief
小题11:
A.saidB.foundC.preparedD.meant
小题12:
A.turned awayB.sat downC.talked backD.gave in
小题13:
A.greetedB.scoldedC.trickedD.comforted
小题14:
A.helpB.ideaC.reward D.comment
小题15:
A.challengedB.attractedC.noticedD.talked
小题16:
A.prideB.angerC.excitementD.joy
小题17:
A.heartB.beginningC.mindD.memory
小题18:
A.panicB.disappointedC.breathlessD.aimless
小题19:
A.downB.upC.aroundD.through
小题20:
A.voiceB.soundC.appearanceD.interest
单项选择题