题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-18 13:35:19

[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程包含有一个源程序文件proj2. cpp,其中定义了Stack类和ArrayStack类。
Stack是一个用于表示数据结构“栈”的类,栈中的元素是字符型数据。Stack为抽象类,它只定义了栈的用户接口,如下所示:
公有成员函数 功能
push 入栈:在栈顶位置添加一个元素
pop 退栈:取出并返回栈顶元素
ArrayStack是Stack的派生类,它实现了Stack定义的接口。ArrayStack内部使用动态分配的字符数组作为栈元素的存储空间。数据成员maxSize表示的是栈的最大容量,top用于记录栈顶的位置。成员函数push和pop分别实现具体的入栈和退栈操作。
请在程序中的横线处填写适当的代码,然后删除横线,以实现上述功能。此程序的正确输出结果应为:
a, b, c
c, b, a
注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//**** found ****”。
// proj2, cpp
#include < iostream >
using namespace std;
class Stack
public :
virtual void push(char c) = 0;
virtual char pop( ) = 0;
;
class ArrayStack : public Stack
char * p;
int maxSize ;
int top ;
public :
ArrayStack( int s)
top = 0;
maxSize = s;
//******** found ********
p =______;

~ ArrayStack ( )

//******** found ********
______;

void push(char c)

更多"请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj"的相关试题:

[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程包含一个源程序文件proj2.cpp。其中定义了Score类。
Score是一个用于管理考试成绩的类。其中,数据成员_s指向存储成绩的数组,_n表示成绩的个数;成员函数Sort使用冒泡排序法将全部成绩按升序进行排列。
请在程序中的横线处填写适当的代码,然后删除横线,以实现Score类的成员函数Sort。
注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。
//proj2.cpp
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
class Score
public:
Score(double * s, int n):_s(s),_n(n)
double GetScore (int i) const return_s[i];
void Sort ( );
private:
double*_s;
int_n;
;
void Score::Sort( )

for(int i=0;i<n-1;______)
//********found********
for(int j=______;j>i;j--)
if(_s[j]<_s[j-1])
//交换_s[j]和_s[j-1]double t=_s[j];
//********found********
______;
//********found********
______;


int main ( )

const int NUM=10;
double s[NUM];
srand(time (0));
for(int i=0;i<NUM;i++)
s[i]=double(rand ( ))/RAND M
[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程中含有一个源程序文件proj2.cpp。函数char * GetNum(char*src,char*buf)从src开始扫描下—个数字字符序列,并将其作为一个字符串取出放入字符串空间buf中。函数返回扫描的终止位置,如果返回NULL表示没有扫描到数字字符序列。
运行程序时,如果输入的一行字符序列是
ABC012XY2378MN274WS
则输出为:
Digit string 1 is 012
Digit string 2 is 378
Digit string 3 is 274
注意:只在横线处编写适当代码,不要删除或移动“//****found****”。
//proj2.cpp
#include <iostream>
using namespace std;
char*GetNum(char*src,char*buf)

while(*src!=’/0’)

if(isdigit(*src)break;

if (*src=="/0")
//********found********
______;
while(*src!=’/0’&& isdigit(*src)

//********found********
______;
buf++;
src++;

*buf=’/0’;
return src;

int main( )

char str[100l,digits[20];
cin.getline(str,100);
char*p=str;
int i=1;
while((p=GetNum(p,digits))!=NULL)

cout<<"Digit string "<<i<<"is "<<digits<<endl;
//********found********
______;<
[简答题]请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,该工程中含有一个源程序文件proj2.cpp,请将堆栈类的定义补充完整。使程序的输出结果为:
The element of stack are:4 3 2 1
注意:请勿修改主函数main和其他函数中的任何内容,只在横线处编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。
//proj2.cpp
#include <iostream>
using namespace std;
const int Size=5;
class Stack;
class Item

public:
//**********found**********
Item(const int&val):______
//构造函数对item进行初始化
private:
int item;
Item* next;
friend class Stack;
;
class Stack

public:
Stack( ):top(NULL)
~Stack( );
int Pop( );
void Push(const int&);
private:
Item*top;
:
Stack::~Stack( )

Item*p=top,*q;
while(p!=NULL)

q=p->next;
//**********found**********
______;//释放p所指向的节点
p=q;


int Stack::Pop( )

Item* temp;
int ret;
//**********found**********
______;//使temp指向栈顶节点
ret=top->item;
top=top->next
[多项选择]请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。此工程包含程序文件main.cpp,其中有类AutoMobile(“汽车”)及其派生类Car(“小轿车”)、Truck(“卡车”)的定义,还有主函数main的定义。请在程序中//************found************下的画线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为:
车牌号:冀ABC1234品牌ForLand类别:卡车当前档位:0最大载重量:1~
车牌号:冀ABC1234品牌ForLand类别:卡车当前档位:2最大载重量:1~
车牌号:沪XY25678品牌QQ类别:小轿车当前档位:0座位数:5
车牌号:沪XY25678品牌QQ类别:小轿车当前档位:-1座位数:5
注意:只能在画线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动
//************found************。
//源程序
#include<iostream>
#include <iomanip>
#include <cmath>
using namespace std;
class AutoMobile //"汽车"类
char*brand; //汽车品牌
char*number; //车牌号
int speed; //档位:1、2、3、4、5,空档:0,倒档:-1
public:
A. ~AutoMobile()delete[] brand; delete[] number;
[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj1下的工程proj1,此工程包含程序文件
main.cpp,其中有类Book(“书”)和主函数main的定义。程序中位于每个//ERROR************found************下的语句行有错,请加以改正。改正后程序的输出应该是:
书名:C++语言程序设计 总页数:299
已把"C++语言程序设计"翻页到第50页
已把“C++语言程序设计"翻页到第51页
已把书合上。
书是合上的。
已把"C++语言程序设计"翻页到第1页
注意:只能修改每个//ERROR************found************下的那一行,不要改动程序中的其他内容。
// 源程序
#include<iostream>
using namespace std;
class Book
char*title;
int num_pages; //页数
int cur_page; //当前打开页面的页码,0表示书未打开
public:
Book(const char*theTitle,int pages):num_pages(pages)
//ERROR************found************
title=new char[strlen(theTitle)];
strcpy(title,theTitle);
cout<<endl<<"书名:"<<title<<"总页数:"<<num_pages;

~Book( )delete[]title;
//ERROR************found************
bool isOpen( ) const return num_pages!=0; //书打开时返回true,否则返回false
int numOfPages( ) const return num_pages; //返回书的页数
int currentPage( ) const return cur_page; //返
[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2,函数void Insert(node*q)使程序能够完成如下功能:从键盘输入一行字符,调用该函数建立反序的无头结点的单链表,然后输出整个链表。
注意:请勿修改主函数main和其他函数中的任何内容,只需在画线处编写适当代码,也不能删除或移动//************found************。
//源程序proj2.cpp
#include<iostream>
using namespace std;
struct node
char data;
node*link:
*head; //链表首指针
void Insert(node*q) //将节点插入链表首部
//************found************
______;
head=q;

int main( )
char ch;
node *p;
head=NULL:
cout<<"Please input the string"<<endl;
while((ch=cin.get( ))!=’/n’)
//************found************
______;//用new为节点p动态分配存储空间
p->data=ch;
//************found************
______; //在链表首部插入该节点

p=head;
while(p!=NULL)
cout<<p->data;
p=p->link;

cout<<endl;
return 0:

[简答题]请使用“答题"菜单或使用VC6打开考生文件夹proj1下的工程proj1,该工程含有一个源程序文件proj1.cpp。程序中位于每个//ERROR************found************下的语句行有错误。请改正这些错误,改正后程序的输出应该是:
1 2 3 4 5 6 7 8 9 10
注意:只修改注释//ERROR************found************下的一行语句,不要改动程序中的其他内容。
//源程序proj1.cpp
#include<iostream>
using namespace std;
class MyClass
public:
MyClass(int len)
array=new int[len];
arraySize=len;
for(int i=0;i<arraySize; i++) array[i]=i+l;

~MyClass( )
//ERROR************found************
delete array[];

void Print( ) const
for(int i=0;i<arraySize; i++)
//ERROR************found************
cin<<array[i]<<";
cout<<endl;

prlvate:
int*array;
int arraySize;

int main( )
//ERROR************found************
MyClass obj;
obj.Print( );
return 0:

[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj3下的工程proj3,其中声明了SorteList类。这是一个用于表示有序数据表的类,其成员函数insert的功能是将一个数据插入到有序表中,使得该数据表仍保持有序。请编写lnsert函数。程序的正确输出应该是:
1,2,4,5,7,8,10
插入6和3后:
1,2,3,4,5,6,7,8,10
要求:补充编制的内容写在//********333********与//料料料料666********两行之间,不得修改程序的其他部分。
注意:程序最后已经将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。
//源程序
#include"SortedList.h"
SortedList:: SortedList(int len, double data[]):len(len)
d=new double[len+2];
for(int k=0; k<len; k++) d[k]=(data==NULL0.0:data[k]);
for(int i=0; i<len-l,i++)
int m=i;
for(int j=i; j<len; j++)
if(d[j]<d[m]) m=j;
if(m>i)
double t=d[m];
d[m]=d[i];
d[i]=t;



void SortedList::insert(double data)
//********333********
//********666********

void SortedList:: show ( ) const //显示有序数据表
for(int i=0; i<len-1,i++) cout<<d[i]<<",";
cout<<d[len-1]<<endl;

int main( )
double s[]=5,8,1,2,10,4,7;
SortedList list(7,s)
[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj3下的工程proj3,其中声明了MyString类。MyString是一个用于表示字符串的类。成员函数startsWith的功能是判断此字符串是否以指定的前缀开始,其参数s用于指定前缀字符串。如果参数s表示的字符串是MyString对象表示的字符串的前缀,则返回true;否则返回false。注意,如果参数s是空字符串或等于MyString对象表示的字符串,则结果为true。
例如:字符串"abc"是字符串"abcde"的前缀,而字符串"abd"不是字符串"abcde"的前缀。请编写成员函数startsWith。在main函数中给出了一组测试数据,此情况下程序的输出应该是:
s1=abcde
s2=abc
s3=abd
s4=
s5=abcde
s6=abcdef
s1 startsWith s2:true
s1 startsWith s3 false
s1 startsWith s4 true
s1 startsWith s5 f true
s1 startsWith s6 false
要求:补充编制的内容写在//********333********与//********666********两行之间,不得修改程序的其他部分。
注意:程序最后已经将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。
//源程序
#include"MyString.h"
bool MyString::startsWith(const char*s)const
//********333******** //********666********

int main( )
char s1[]="abcde";
char s2[]="abc";
char s3[]="abd";
char s4[]=" ";
char s5[]="abcde";
char s6[]="abcdef";
MyString str(s1)
[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj3下的工程proj3,其中声明了DataList类,这是一个用于表示数据表的类。sort成员函数的功能是将当前数据表排序,使得表中的元素呈升序排列。请编写这个sort函数。程序的正确输出应该是:
排序前:7,1,3,11,6,9,12,10,8,4,5,2
排序后:1,2,3,4,5,6,7,8,9,10,11,12
要求:补充编制的内容写在//********333********与********666********两行之间,不得修改程序的其他部分。
注意:程序最后已经将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。
//源程序
#include"DataList.h"
DataList:: DataList(int len, double data[]):len(len)
d=new double[len];
for(int i=0; i<len; i++) d[i]=(data==NULL0.0:data[i]);

void DataList::sort( )//数据表排序
//********333********
//********666********

void DataList::show( ) const//显示数据表
for(int i=0; i<len-1,i++) cout<<d[i]<<",";
cout<<d[len-1]<<endl;

int main( )
double s[]=7,1,3,11,6,9,12,10,8,4,5,2;
DataList list(12,s);
cout<<"排序前:";
list.show( );
list.sort( );
cout<<endl<<"排序后:";
list.show( );
//writeToFile("K://b10//61000102//",list);
return 0:

[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj1下的工程proj1,其中有枚举DOGCOLOR、狗类Dog和主函数main的定义。程序中位于每个//ERROR************found************下的语句行有错误,请加以改正。改正后程序的输出应该是:
There is a white dog named Hoho.
There is a black dog named Haha.
There is a motley dog named Hihi.
注意:只能修改每个//ERROR************found************下的那一行,不要改动程序中的其他内容。
//源程序
#include <iostream>
using namespace std;
//狗的颜色:黑、白、黄、褐、花、其他
enum DOGCOLOR BLACK,WHITE,YELLOW,BROWN,PIEBALD,OTHER;
class Dog//狗类
DOCCOLOR color;
char name[20];
static int count;
public:
Dog(char name[],DOGCOLOR color)
strcpy(this->name,name);
//ERROR************found************
strcpy(this->color,color);

DOGCOLOR getColor( ) const return color;
//ERROR************found************
const char*getName( ) const return*name;
const char*getColorString( ) const
switch(color)
case BLACK: return"black";
case WHITE: return"white";
case YELLOW: return"yello
[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj3下的工程proj3,其中声明了VaIArray类,该类在内部维护一个动态分配的整型数组。ValArray类的复制构造函数应实现对象的深层复制。请编写ValArray类的复制构造函数。在main函数中给出了一组测试数据,此情况下程序的输出应该是:
ValArray v1=1,2,3,4,5
ValArray v2=1,2,3,4,5
要求:补充编制的内容写在//********333********与//********666********两行之间,不得修改程序的其他部分。
注意:程序最后已经将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。
//源程序
#include"ValArray.h"
VaIArray:: VaIArray(const ValArray& other)

//********333********
//********666********
int main( )
const int a[]=1,2,3,4,5 ;
ValArray v1(a,5);
cout<<"ValArray v1=";
v1.print(cout);
cout<<endl;
ValArray v2(v1);
cout<<"ValArray v2=";
v2.print(cout);
cout<<endl;
// writeToFile("K: //b10 //61000101 //");
return 0;

[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2,其中声明了CDeep-Copy类,它是一个用于表示动态数组的类。请编写其中的复制构造函数。
要求:补充编制的内容写在//********333********与//********666********两行之间,不得修改程序的其他部分。
注意:程序最后已经将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。
//源程序
#include"CDeepCopy.h"
CDeepCopy::~CDeepCopy( )delete[]p;
CDeepCopy::CDeepCopy(int k)n=k; p=new int[n]; //构造函数实现
CDeepCopy::CDeepCopy(const CDeepCopy&r) //复制构造函数
//********333********
//********666********

int main( )
CDeepCopy a(2),d(3);
a.p[0]=1; d.p[0]=666; //对象a、d数组元素的赋值

CDeepCopy b(a);
a.p[0]=88;
cout<<b.p[0]; //显示内层局部对象的数组元素

cout<<d.[0]; //显示d数组元素a.[0]的值
cout<<"d fade away; /n";cout<<a.p[0]; //显示a数组元素a.p[0]的值
//writeToFile("K://bl0//61000101//");
return 0:

[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2,其中包含抽象类Shape的声明,以及在此基础上派生出的类Rectangle和Circle的声明,二者分别是计算面积的函数GetArea( )和计算对象周长的函数GetPerim( )。程序中位于每个//************found************下的语句行有错,请加以改正。改正后程序的输出应该是:
The area of the Circle is 78.5
The perimeter of the Circle is 31.4
The area of the Rectangle is 24
The perimeter of the Rectangle is 20
注意:只能在画线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动“//************found************”。
//源程序
#include<iostream>
using namespace std;
class Shape
public:
Shape( )
~Shape( )
//************found************
______float GetArea( )=0;
//************found************
______float GetPerim( )=0;

class Circle: public Shape
public:
Circle(float radius):itsRadius(radius)
~Circle( )
float CetArea( ) return 3.14 *itsRadius *itsRadius;
float CetPerim( )return 6.28 *itsRadius;
private:
float itsRadius:

class Rectangle: public Shape
public:
//**
[简答题]请使用“答题”菜单或使用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]);

//**********
[简答题]请使用“答题”菜单或使用VC6打开考生文件夹proj1下的工程proj1。此工程定义了Stop-Watch(秒表)类,用于表示时、分、秒信息,有构造函数StopWatch( )、设置时间函数reset( )、并且重载了前置和后置++运算符,用于实现增加秒的功能。程序中位于每个//ERROR************found************下的语句行有错误,请加以改正。改正后程序的输出应该是:
00:00:00
00:01:00
注意:只能修改每个//ERROR************found************下的那一行,不要改动程序中的其他内容。
//源程序
#include<iostream>
#include<iomanip>
using namespace std;
class StopWatch //“秒表”类
int hours,minutes,seconds; //小时、分钟、秒
public:
StopWatch( ):hours(0),minutes (0),seconds(0)
void reset( )hours=minutes=seconds=0;
StopWatch operator++(int) //后置++
StopWatch old=*this;
++(*this);
return old;

//前进1秒
StopWatch& operator++( ) //前置++
//ERROR************found************
if(seconds++==60)
seconds=0;minutes++;
if(minutes==60)
minutes=0;hours++;


//ERROR************found************
return this:

friend void show(StopWatch);

void show(StopWatch watc
[多项选择]请使用“答题”菜单或使用VC6打开考生文件夹proj1下的工程proj1。程序中位于每个//ERROR************found************下的语句行有错,请加以改正。改正后程序的输出应该是:
Name:Smith Age:21 ID:99999 CourseNum:12 Record:970
注意:只能修改每个//ERROR************found************下的那一行,不要改动程序中的其他内容。
//源程序
#include<iostream>
using namespace std;
class StudentInfo
protected:
//ERROR************found************
char Name[];
int Age;
int ID;
int CourseNum;
float Record:
public:
//ERROR************found************
void StudentInfo(char*name, int age, int ID, int courseNum,float record);
//ERROR************found************
void~StudentInfo( )delete[]Name;
float AverageRecord( )
return Record/CourseNum:

void show( ) consL;

StudentInfo::StudentInfo(char*name, int age, int ID, int courseNum, float record)
Name=strdup(name);

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码