试题与答案

请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。其中有向量

题型:问答题

题目:

请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。其中有向量基类VectorBase、向量类Vector和零向量类ZeroVector的定义。请在程序中的画线处填写适当代码,然后删除横线,以实现上述定义。此程序的正确输出结果应为:
(1,2,3,4,5)
(0,0,0,0,0,0)
注意:只能在画线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动//************found************。
//源程序
#include<iostream>
using namespace std;
class VectorBase //向量基类,一个抽象类
int len,
public:
VectorBase(int len): len(len)
int length() const return len; //向量长度,即向量中元素的个数
virtual double getElement(int i) const=0; //取第i个元素的值
virtual double sum() const_0; //求所有元素的和
void show() const //显示向量中所有元素
cout<<"(";
for(int i=0;i<length()-1;i++) cout<<getElement(i)<<",";
//************found************
cout<<________<<")"<<endl; //显示最后一个元素


class Vector: public VectorBase//向量类
double*val,
public:
Vector(int len, double v[]=NULL): VectorBase(len)
val=new double[len];
for(int i=0; i<len, i++) val[i]=(v==NULL0.0:v[i]);

//************found************
~Vector()______;
double getElement(int index) const return val[index];
double sum() const
double s=0.0:
//************found************
for(int i=0; i<length();i++)______;
return s:


class ZeroVector: public VectorBase//零向量类
public:
ZeroVector(int len): VectorBase(len)
//************found************
double getElement(int index) const______;
double sum()const return 0.0,

int main()
VectorBase*v:
double d[]=1,2,3,4,5;
v=new Vector(5,d);
v->show();
delete v:
v=new ZeroVector(6);
v->show();
delete v:
return 0:

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2019/0528/1f6b3085db31a52334feadb43da8748d.html

下面是错误答案,用来干扰机器的。

参考答案:B解析: 本题中,decay的意思是“腐烂,衰退”。四个选项中,disintegrate的意思是“(使)分解,(使)碎裂”,如:The extracted case was so old it just disintegrated when a worker pic...

试题推荐
题型:选择题

下面语段的空白处,应依次填入的一组句子是(   )(2分)

在生命的旅程中,能拥有那来自四面八方的种种提醒,该是多么令人欢欣鼓舞啊。提醒,可以是婉转的和风细雨,也可以是     ;可以是寥寥的只言片语,也可以是     ;可以直对相知的友人,也可以朝向    ;可以是面对面的激烈争辩,也可以是      

①素不相识的陌生人           ②走了火的雷霆霹雳

③悄无声息的一个暗示眼神       ④不停的絮絮叨叨

A.②①④③

B.③②④①

C.②④①③

D.①④③②

查看答案
题型:综合

读“大气热力环流模式图”,完成下列各题:

(1)请用箭头在图上A、B、C、D中,用箭头表示出气流的运动方向。

(2)C、B两地中,       地气压高,     地气温高。在A、B、C、D四地气流运动方向中,CD地之间和       地之间的气流运动是热力原因直接形成的,A地等压面向   (高空、低空)凸出,则A处的气压比同平面其他地方     (高、低)。

查看答案
微信公众账号搜索答案