4π
8π
12π
16π
64π
第1题:
阅读以下说明和C代码,将应填入(n)处的字句写在的对应栏内。
【说明】
在一个简化的绘图程序中,支持的图形种类有点(point)和圆(circle),在设计过程中采用面向对象思想,认为所有的点和圆都是一种图形(shape),并定义了类型shape t、 point t和circle t分别表示基本图形、点和圆,并且点和圆具有基本图形的所有特征。
【C代码】
typedef enum { point,circle } shape type; /* 程序中的两种图形:点和圆 */
typedef struct { /* 基本的图形类型 */
shape_type type; /* 图形中类标识:点或者圆*/
void (*destroy) (); /* 销毁图形操作的函数指针*/
void (*draw) (); /* 绘制图形操作的函数指针*/
} shape_t;
typedef struct { shape_t common; int x; iht y; } point_t; /* 定义点类
型, x, y为点坐标*/
void destroyPoint (point_t* this) { free (this); printf ("Point destoryed!
\n"); } ) /* 销毁点对象*/
void drawPoint(point_t* this) { printf("P(%d,%d)", this->x, this->y); }
/* 绘制点对象*/
shape_t* createPoint (va_list* ap) (/* 创建点对象,并设置其属性*/
point_t* p_point;
if ( (p_point= (point_t*)malloc (sizeof (point_t)) ) ==NULL) returnNULL;
p_point->common, type = point; p_point->common, destroy = destroyPoint;
p_point->common.draw = drawPoint;
p_point->x = va_arg(*ap, int); /* 设置点的横坐标*/
p_point->y = va_arg(*ap, int); /* 设置点的纵坐标*/
return (shape_t*)p_ooint; /*返回点对象指针*/
}
typedef struct { /*定义圆类型*/
shape_t common;
point_t 4center; /*圆心点*/
int radius; /*圆半径*/
} circle_t;
void destroyCircle(circle_t* this){
free((1)); free(this); printf("Circle destoryed!\n");
}
void drawCircle(circle_t* this) {
print f ("C (");
(2).draw(this->center); /*绘制圆心*/
printf(",%d) ", this->radius);
}
shape_t* createCircle(va_list4 ap) { /*创建一个圆,并设置其属性*/
circle_t4 p circle;
if ((p_circle = (circle_t4)malloc (sizeof (circle_t)) ) ==NULL ) return NULL;
p_circle->common.type = circle; p_circle->common.destroy = destroy
Circle;
p_circle->common.draw = drawCircle;
(3) = createPoint(ap); /* 设置圆心*/
p_circle->radius = va_arg(*ap, int); /* 设置圆半径*/
return p_circle;
}
shape_t* createShape(shape_type st, "') { /* 创建某一种具体的图形*/
va_list ap; /*可变参数列表*/
&nbs
第2题:
阅读下列程序说明和C++代码,将应填入(n)处的字句写在对应栏内。
[说明]
①为类Circle增加一个构造函数,该函数有一个参数,并在构造时将该参数值赋给成员 radius。将该函数实现为一个非内联函数,并且使用参数列表的方式将类成员赋值。
②为类Circle增加一个成员函数print(),使得可以输出有关圆的信息,比如下列程序
Circle c;
c. SetRadius(5);
c. Print();
将输出:The circle has radius of 5!
③完成友元函数void CompareR(Circle *c1,Circle *c2)的定义,在屏幕中输出c1与c2比较radius大小结果,要求使用if - else结构完成。
输出结果如下:
The circle has radus of 5 !
The circle has radius of 10 !
cl <c2
源程序文件test7_3, cpp 清单如下:
include < iostream, h >
class Circle {
public:
Circle( ) :radius(5) {}
(1)
void SetRadius(int r) { radius = r; }
int GetRadius() { return radius; }
(2)
friend void CompareR(Circle * c1,Circle * c2);
private:
int radius;
};
void CompareR(Circle * c! ,Circle * c2)
{
(3)
cout << "c1 > c2" << endl;
else
if ( (c1 -> GetRadius( )) == (c2 -> GetRadius( )))
tout < <"c1=c2' < < endl;
else
if ( (c1 -> GetRadius( )) < ( c2 -> GetRadius( )))
cout <<"c1<c2" <<endl;
void main( )
Circle c1
c1. SetRadius(5)
c1. Print( )
Circle c2(10);
c2. Print( )
CompareR(&c1 ,&c2);
}
第3题:
有如下程序: #include<iostream> usingnamespacestd; classPoint{ intX,Y; public point(intx1=0,inty1=O)tx(x1),y(y1){} intget(){returnx+y;} }; classCircle{ pointcenter; intradius; public circle(intCX,intcy,intr):center(cx,cy),radius(r) {} intget(){returncenter.get()+radius;) }; intmain(){ circlec(3,4,5); cout<<c.get()<<endl; return0; } 运行时的输出结果是( )。
A.5
B.7
C.9
D.12
第4题:
根据程序中的注释将下列缺失部分补充完整。
class Point{
int x,y; //点的x和y坐标
public:
Point(int xx=0,int yy=0):x(xx),y(yy){}
};
class Circle{
Point center;//圆心位置
int radius; //半径
public: //利用cx和cY分别初始化圆心的x和y坐标
circle(int cx,int cy,int r): 【 】 ,radius(r){}
void area()(cout<<3.14159*radius*radius<<end1;)
};
第5题:
第6题:
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()
第7题:
A curved line drawn on a Mercator Chart
A course line that inscribes a loxodromic curve
The shortest distance between any two points on the earth
The smallest circle that can be drawn on the face of a sphere
第8题:
第9题:
y=3x+2
y=2x+1
y=-x+5
y=-2
y=-6
第10题:
3/2
2/3
4/9
1/4
9/4
第11题:
advance
drift angle
pivoting point
transfer
第12题:
16%
20%
40%
80%
96%
第13题:
使用VC6打开考生文件夹下的工程test9_3,此工程包含一个源程序文件test9_3.cpp,其中定义了Circle类与Money类, Circle类可对半径为r的圆进行周长与面积的计算,而Money类用于计算一圆形游泳池的造价。游泳池四周有原形过道,过道外围上栅栏,过道宽度为3米,根据键入的游泳池半径,每米栅栏价格及每平方米过道价格,即可计算出游泳池的造价。请按要求完成下列操作,将程序补充完整。
(1)定义符号常量PI(值为3.14159f)与WIDTH(值为3.00f),分别用于表示圆周率与过道的固定宽度。请在注释“//**1**”之后添加适当的语句。
(2)定义Circle类默认构造函数,把私有成员radius初始化为参数r的值。请在注释 “//**2**” 后添加适当的语句。
(3)完成Money类默认构造函数的定义,把私有成员FencePrice(每米栅栏的价格)、ConcretePrice(每平方米过道的价格)初始化为参数f,c的值。请在注释“//**3**”之后添加适当的语句。
(4)完成Money类成员函数floatMoney::TotalMoney(noat fencelen,float conarea)的定义,根据参数fencelen(栅栏的长度)和conarea(过道的面积),返回栅栏与过道的总造价。请在注释“//**4**”之后添加适当的语句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
源程序文件test9_3.cpp清单如下:
include<iostream.h>
//**1**
class Circle
{
private:
float radius;
public:
//**2**
float Circumference(){return 2 * PI * radius;)
float Area(){return PI * radius * radius;)
};
class Money
{
private:
float FencePrice;
float ConcretePrice;
public:
Money(float f,float c);
float TotalMoney(float fencelen, float conarea);
};
Money::Money(float f,float c)
{
//**3**
}
float Money::TotalMoney(float fencelen,float conarea)
{
//**4**
}
void main()
{
float radius,fence,concrete;
cout.setf(10s::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<"Enter the radius of the pool:";
cin>>radius;
cout<< "Enter the FencePrice:";
cin>>fence;
cout<<"Enter the ConcretePrice:";
cin>>concrete;
Circle Pool(radius);
Circle PoolRim(radius + WIDTH);
Money mon(fence,concrete);
float totalmoney=mon.TotalMoney(PoolRim.Circumference(),(PoolRim.Area() - P00l.Area()));
cout<<"The total money is RMB"<<totalmoney<<endl;
}
第14题:
有如下程序:
#include<iostream>
using namespace std;
class Point{
int x, y;
public:
Point(int x1=0, int y1=0):x(x1), y(y1){}
int get(){return x+y;)
};
class Circle{
Point center;
int radius;
public:
Circle(int CX, int cy, int r):center(cx, cy), radius(r){}
int get(){return center. get()+radius;}
};
int main(){
circle c(3, 4, 5);
cout<<c. get()<<end1;
return ():
}
运行时的输出结果是( )。
A) 5
B) 7
C) 9
D) 12
A.
B.
C.
D.
第15题:
阅读下列程序说明和C++代码,将应填入(n)处。
【说明】
源程序中定义了Circle类与Money类,Circle类可对半径为r的圆进行周长与面积的计算,而Money类用于计算一圆形游泳池的造价。游泳池四周有原形过道,过道外围上栅栏,过道宽度为3米,根据键入的游泳池半径,每米栅栏价格及每平方米过道价格,即可计算出游泳池的造价。请按要求完成下列操作,将程序补充完整。
①定义符号常量PI(值为3.14159f)与WIDTH(值为3.00f),分别用于表示圆周率与过道的固定宽度。
②定义Circle类默认构造函数,把私有成员radius初始化为参数r的值。
③完成Money类默认构造函数的定义,把私有成员FencePrice(每米栅栏的价格)、ConcretePrice(每平方米过道的价格)初始化为参数f,c的值。
④完成Money类成员函数float Money::TotalMoney(float fencelen,float conarea)的定义,根据参数fencelen(栅栏的长度)和conarea(过道的面积),返回栅栏与过道的总造价。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
源程序文件test4.cpp清单如下:
include<iostream.h>
(1)
class Circle
{
private:
float radius;
public:
(2)
float Circumference(){return 2 * P| * radius;}
float Area(){return P|*radius * radius;}
};
class Money
{
private:
float FencePrice;
float ConcretePrice;
public:
Money(float f,float c);
float Tota|Money(float fencelen, float conarea);
};
Money::Money(float f,float c)
{
(3)
}
float Money::Tota|Money(float fencelen, float conarea)
{
(4)
}
void main( )
{
float radius, fence, concrete;
cout. setf(ios:: fixed);
cout. setf(ios:: showpoint);
cout. precision (2);
cout << "Enter the radius of the pool:";
cin > > radius;
cout << "Enter the FencePrice:";
cin > > fence;
cout << "Enter the ConcretePrice: ";
cin > > concrete;
Circle Pool(radius);
Circle PoolRim(radius + WIDTH);
Money mon( fence, concrete);
float totalmoney = mon. TotalMoney( PoolRim. Circumference( ), ( PoolRim. Area ( ) - Pool.
Area ( ) ) );
cout << "The total money is RMB" << totalmoney << end|;
}
第16题:
第17题:
第18题:
6π-2πx
6π-πx2
12π-2πx
36π-2πx
36π-πx2
第19题:
gained at right angles to the original course
gained in the direction of the original course
moved sidewise from the original course when the rudder is first put over
around the circumference of the turning circle
第20题:
13n
17n
26n
34n
60n
第21题:
2A
4A
8A
16A
32A
第22题:
Ⅰ only
Ⅱ only
Ⅲ only
Ⅰ, Ⅱ and Ⅲ
Ⅱ and Ⅲ only
第23题:
public class Circle implements Shape { private int radius; }
public abstract class Circle extends Shape { private int radius; }
public class Circle extends Shape { private int radius; public void draw(); }
public abstract class Circle implements Shape { private int radius; public void draw(); }
public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }