更多"请使用“答题”菜单或使用VC6打开考生文件夹proj3下的工程proj"的相关试题:
[简答题]请使用“答题”菜单或使用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打开考生文件夹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打开考生文件夹proj1下的工程proj1。此工程包含程序文件main.cpp。程序中位于每个//ERROR************found************下的语句行有错误,请加以更正。更正后程序的输出应该是:
1958年3月23日比2001年11月5日更早
2001年11月5日比1958年3月23日更晚
2001年11月5日与2001年11月5日是同一日期
注意:只能修改每个//ERROR************found************下的那一行,不要改动程序中的其他内容。
//源程序
#include <iostream>
using namespace std;
class Date
int year;
int month;
int day;
public:
//ERROR************found************
Date(int yyyy, int mm, int dd): yyyy(year),mm(month),dd(day)
bool isLaterThan(Date dt) const //当前日期晚于日期dt时返回true
if(year!=dt.year) return year>dt.year;
if(month!=dt.month) return month>dt.month;
return day>dt.day;
bool isEarlyThan(Date dt) const //当前日期早于日期dt时返回true
if(year!=dt.year) return year<dt.year;
if(month !=dt.month) return month<dt.month;
//ERROR************found************
return day>dt.day;
void showDate( ) const cout<<year<<"年"<<month<<"月"<<day<<"日";<
[多项选择]请使用“答题”菜单或使用VC6打开考生文件夹proj2下的工程proj2。此工程包含一个程序文件main.cpp,其中的Array是一个表示数组的模板类。Array的成员a用于指向存放数据的数组,size表示该数组的大小。此程序的输出结果应为:
8
29,20,33,12,18,66,25,14
66,33
注意:只能在画线处填写适当的代码,不要改动程序中的其他内容,也不能删除或移动//************found************。
//源程序
#include <iostream>
#include <cstdlib>
using namespace std;
template<class Type>
class Array//数组类
Type *a;
int size;
public:
A. for(int i=0; i<size; i++) a[i]=b[i];
B. i>=size)cout<<"下标越界!"<<endl;exit(1);
C. return a[i];;
D. //由x1和x2带回数组a中的两个最大值
E. template<class Type>
F. void Array<Type>::MaxTwo(Type& x1,Type& x2) const //补充完整函数体的内容
G. //将数组a中头两个数据赋值给x1和x2,使得x1>=x2
H. ______(x1=a[0],x2=a[1]):(x1=a[1],x2=a[0]);
I. for(int i=2;i<size; i++)
J. if(a[i]>x1)x2=x1; x1=a[i];
K. else if(a[i]>x2) x2=a[i];
L. void main()
M. int s1[8]=29,20,33,12,18,66,25,14;Array<int> d1(s1,8);
N. int i,a,b;
O. d1.M axTwo(a,b);
P. cout<<d1.Length()<<endl;
Q. for(i=0;i<7;i++) cout<<d1[i]<<",";
R. cout<<d1[7]<<endl;cout<<a<<","<<b<<endl;
[简答题]使用“答题”菜单或从VC6中打开考生文件夹proj2下的工程proj2。此工程包含一个程序文件main.cpp,其中有类Quadritic、类Root以及主函数main的定义。一个Quadritic对象表示一个ax2+bx+c的一元二次多项式。一个Root对象用于表示方程ax2+bx+c=0的一组根,它的数据成员num_of_roots有3种可能的值0、1和2,分别表示根的3种情况:无实根、有两个相同的实根和有两个不同的实根。请在程序中的画线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为(注:输出中的X^2表示x2):
3X^2+4X+5=0.0 无实根
4.5X^2+6X+2=0.0 有两个相同的实根: -0.666667和-0.666667
1.5X^2+2X-3=0.0 有两个不同的实根: 0.896805和-2.23014
//源程序
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
class Root //一元二次方程的根
public:
const double x1; //第一个根
const double x2; //第二个根
const int num_of_roots; //不同根的数量:0、1或2
Root( ):x1(0.0),x2(0.0),num_of_roots(0) //创建一个“无实根”的Root对象
Root(double root)
//************found************
:______ //创建一个“有两个相同的实根”的Root对象
Root(double root1,double root2)
:x1(root1),x2(root2),num_of_roots(2) //创建一个有两个不同的实根的Root对象
void show( ) const //显示根的信息
[简答题]请使用“答题”菜单或使用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,其中有枚举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中打开考生文件夹proj1下的工程proj1。此工程包含了类Pets(“宠物”)和主函数main的定义。程序中位于每个//ERRO************found************下的语句行有错,请加以改正。改正后程序的输出结果是:
Name: sonny Type: dog
Name: John Type: dog
Name: Danny Type: cat
Name: John Type: dog
注意:只能修改每个//ERROR************found************下的那一行,不要改动程序中的其他内容。
//源程序
#include <iostream>
using namespace std;
enum Pets_typedog,cat,bird,fish;
class Pets
private:
char*name:
Pets_type type;
public:
Pets(const char*name="sonny",Pets_type type=dog);
Pets& operator=(const Pets &s);
~Pets( );
void show( ) const;
;
Pets::Pets(const char*name,Pets_type type) //构造函数
this->name=new char[strlen(name)+1];
strcpy(this->name,name);
//ERROR************found************
type=type;
Pets::~Pets( ) //析构函数,释放name所指向的字符串
//ERROR************found************
name=’/0’:
Pets&Pets::operator=(const Pets &s)
if(&s==this) return*this;
[简答题]使用VC6打开考生文件夹下的工程MyProj6。此工程包含一个源程序文件MyMain6.cpp。在程序中,定义了一个Furniture类,Bed类和Sofa类是在Furniture类的基础上按公有继承的方式产生的派生类,Sleepersofa类是在Bed类和Sofa类的基础上按公有继承的方式产生的派生类。
请按要求完成下列操作,将类Date的定义补充完成:
①Bed类是在Furniture类的基础上按公有继承的方式产生的派生类,为了使程序中的多重继承关系不出现二义性。请在注释“//**1**”之后添加适当的语句。
②Sofa类是在Furniture类的基础上按公有继承的方式产生的派生类,为了使程序中的多重继承关系不出现二义性。请在注释“//**2**”之后添加适当的语句。
③Sleepersofa类是在Bed类和Sofa类的基础上按公有继承的方式产生的派生类。请在注释“//**3**”之后添加适当的语句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
源程序文件MyMain6.cpp清单如下;
//MyMain6.cpp
#include<iostream>
using namespace std;
class Furniture
public:
Furniture( )
void setweight(int w)
weight=w;
int getweight( )
return weight;
protected:
int weight;
;
//* *1 * * class Bed definition
public:
Bed( )
void sleep( )
cout<<"sleeping..."<<end1;
;
//* *2* * class Sofa definition
public:
Sofa( )
[简答题]请在“答题”菜单下选择相应的命令,完成下面的内容:
注意:下面出现的所有文件都必须保存在考生文件夹下。
打开http://localhost/gwyks.html页面,浏览“全国计算机等级考试一级MS OFFICE——公务员考试”页面,并将页面以文本文件类型保存到考生文件夹下,名称为“web4.txt”。