Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Computer Grade Examination Written Test Paper Level 2 C Language
Computer Grade Examination Written Test Paper Level 2 C Language
Choose 35 to fill in the blanks, 15, with 2 points for each question.

20 10 written examination questions of computer grade examination level 2 C++

First, multiple-choice questions (2 points for each small question, 70 points for * * *)

Of the following four options a), b), c) and d), only one option is correct. Please fill in the correct options in the corresponding position on the answer sheet, and the answers will not be scored on the test paper.

(1) The following statement is correct.

A) Search for an ordered linked list with a length of n, and in the worst case, the number of comparisons required is n..

B) method of bisection is performed on an ordered linked list of length n, and the number of comparisons required in the worst case is (n/2).

C) method of bisection the ordered linked list with the length of n, and in the worst case, the comparison number is (log2n).

D) method of bisection is performed on an ordered linked list with length n, and the worst-case comparison number is (n log2n).

(2) The time complexity of the algorithm refers to

A) the execution time of the algorithm

B) the amount of data processed by the algorithm

C) the number of statements or instructions in the algorithm program

D) The number of basic operations required by the algorithm in the execution process.

(3) Software can be divided into application software, system software and supporting software (or tool software) by function. The following belong to the system software

A) editing software

B) operating system

C) education management system

D) browser

(4) The task of software (program) debugging is

A) Diagnose and correct errors in the procedure.

B) Find as many errors as possible in the program.

C) Find and correct all errors in the program.

D) determine the nature of the error in the program

(5) The data flow chart (DFD chart) is

A) software outline design tools

B) detailed software design tools

C) Requirements analysis tools for structured methods

D) Requirements analysis tool of object-oriented method

(6) The software life cycle can be divided into definition stage, development stage and maintenance stage. Detailed design belongs to

A) definition stage

B) development stage

C) maintenance phase

D) the above three stages

(7) The language responsible for data schema definition in the database management system is

A) data definition language

B) data management language

C) data manipulation language

D) data control language

(8) In the relational database of student management, the data unit for accessing student information is

A) documents

B) database

C) site

D) record

(9) In database design, E-R diagram is used to describe the information structure, but it does not involve the representation of information in the computer, which belongs to database design.

A) demand analysis stage

B) logic design stage

C) conceptual design stage

D) physical design stage

(10)R and t have the following two relationships:

Then the operation of obtaining the relation T from the relation R is

A) choose

B) projection

C) salary

D) and

(1 1) In the following function description, the error is

A) The function can have no return value.

B) Functions can have no parameters.

C) A function can be a member of a class.

D) Functions cannot be defined as templates.

(12) If MyClass is a class name and has the following statement sequence.

MyClass c 1,* c2

MyClass * c3 = new myclass;

MyClass & ampC4 = c 1;

The number of class objects defined in the above statement sequence is

A) 1

B)2

C)3

D)4

(13) In the following description of inheritance mode, the error is

A) If an inheritance method is not explicitly specified, the default inheritance method is private.

B) When public inheritance is adopted, the public members in the base class are still public members in the derived class.

C) When protected inheritance is adopted, the protected member in the base class is still the protected member in the derived class.

D) When private inheritance is adopted, the private members in the base class are still private members in the derived class.

(14) Overloaded the prefix operator "-"as a non-member function. In the following prototype, it can be used correctly in the class.

a)Decr & amp; Operator-(int);

Decr operator-(decr &; ,int);

C) friend Decr & operator-(decr & );

D) operator-(frlend decr &; ,int);

(15) If MyTemp is a class template with only one virtual type parameter and has the following statement sequence.

MyTempp2

mytempp 3[2];

When the compilation system processes the above statement sequence, the number of instances of the generated template MyTemp is

A) 1

B)2

C)3

D)0

(16) In C++, cin is

A) category

B) objects

C) template

D) function

(17) Among the following characters, those that are not allowed as C++ identifiers are

A)b)

B)B

C)_

D)2

(18) In the following statement, the error is

A)false is a logical constant.

B) "b" is a character constant.

C)365 is an int constant.

D)3. 14 15926 is a double constant.

(19) if X and Y are two integer variables in the program, the following if statement is correct.

a)if(x = = 0)y = 1; Otherwise y = 2;;

B) if (x==0), then y= 1 otherwise y = 2;;

c)if(x = = 0)y = 1 else y = 2;

D) If x = = 0y =1; Otherwise y = 2;;

(20) Defining an integer array X contains three elements, with an initial value of O. The following statement is wrong.

A)int x[3]={0,0,0 };

b)int x[]= { 0 };

c)static int x[3]= { 0 };

D)int x[]={0,0,0 };

(2 1) What is wrong in the following statement?

a)& lt; Return type > may contain the keyword int.

b)& lt; Return type > can be found in the.

c)& lt; Return type > can contain characters *

d)& lt; Return type > may contain [].

(22) to define the reference variable p to refer to the object of MyClass, the correct definition statement is

a)my class p = my class;

B)my class p = new myclass;

c)my class & amp; P = new MyClass

D) my a level. p = a;

(23) Category has the following two definitions.

Class XX

Private:

Double x1;

Protected:

Double x2;

Public:

Double x3;

};

YY level: protected XX{

Private:

Double y1;

Protected:

Double y2;

Public:

Double y3;

};

The number of protected member variables in YY class is

A) 1

B)2

C)3

D)4

(24) The following description about operator overloading is wrong.

A) You can create new operators in C++ through operator overloading.

B) Assignment operators can only be overloaded as member functions.

C) When the operator function is overloaded as a member function of a class, the first operand is a class object.

D) You don't need to declare the return type when overloading the type conversion operator.

(25) In the following description of class templates, the mistake is that

A) The member functions of a class template are all template functions.

B) Default values can be set for class template parameters.

C) A class template describes a set of classes

D) Only one type parameter is allowed in the class template.

(26) Among the following operators that control the input and output of formats, the ones that can set the precision of floating-point numbers are

A) set the accuracy

B)setw

C) setting the padding

D) The program segment below D)showpoint(27) contains four functions, among which this pointer is implied.

int fun 1();

Category test {

Public:

int fun 2();

friend int fun3();

static int fun 4();

};

A)fun 1

B)fun2

C)fun3

D) fun 4

(28) There are the following procedures

# Including

Use namespace std

Category test {

Public:

Test () {

Test (const test & ampt) {cout <; & lt 1; }

};

Test fun (test & ampu){ test t = u;; return t; }

int main(){Test x,y; X = fun (y); Returns 0; }

The output of running this program is

A) no output

B) 1

C) 1 1

D) 1 1 1

(29) There are the following procedures

# Including

Use namespace std

Level a

Public:

A(int i=0):r 1(i) { }

void print(){ cout & lt; & ltE ' & lt& ltr 1 & lt; & lt'-'; } & ltp & gt

void print()const { cout & lt; & ltC ' & lt& ltr 1 * r 1 & lt; & lt'-'; } & ltp & gt

void print(int x){ cout & lt; & ltP ' & lt& ltr 1 * r 1 * r 1 & lt; & lt'-'; } & ltp & gt

Private:

int r 1;

};

int main() {

a a 1;

const A a2(4);

a 1 . print(2);

a 1 . print();

Returns 0;

}

The output of the runtime is

A)P8-E4

P8-C 16-

C)P0-E4-

D)P0-C 16-

(30) The following code declares three classes

Humanoid {};

Class students: public figures {};

Class undergraduate: student {};

The following descriptions of these relationships are wrong.

A) Class characters are the basic classes for class undergraduates.

B) Class undergraduates openly inherit class students.

C) class Student is a derived class of class Person.

D) Class undergraduate is a derived class of class human.

(3 1) has the following procedures

# Including

Use namespace std

Category basis {

Public:

base(int x = 0):valB(x){ cout & lt; & ltVALB} & ltp & gt

~ Base(){ cout & lt; & ltVALB} & ltp & gt

Private:

int valB

};

Class derivation: public Base{

Public:

Derived(int x=0,int y=0):Base(x),valD(y){ cout & lt; & ltVALD; } & ltp & gt

~ Derived(){ cout & lt; & ltVALD; } & ltp & gt

Private:

int valD

};

int main(){

Derive obj12 (2,3);

return 0;

}

The output of the runtime is

A)2332

B)2323

3232

3223

(32) The following is the definition of class shape:

Category shape {

Public:

Virtual void Draw()= 0;;

};

The following description of the Shape class is correct.

A) The class shape is a virtual base class.

B) class Shape is an abstract class.

C) the Draw function in class Shape is incorrectly declared.

D) state "shape s;" Objects that can create shapes.

(33) Overload the operator "+"as a non-member function. In the following prototype statement, the error is

A)MyClock operator+(MyClock, long);

B)MyClock operator+(MyClock, myclock);

C)MyClock operator+(long, long);

D)MyClock operator+(long, my clock);

(34) When opening a file, you can use the following file opening modes alone or in combination.

①IOs _ base::app②IOs _ base::binary

③ios_base::in ④ios_base::out

To open a file in binary reading mode, the file opening mode to be used is

A)①③

B)①④

C)②③

D)②④

(35) There are the following procedures:

# Including

Use namespace std

Class b {

Public:

b(int xx):x(xx){ ++ cout; x+= 10; }

Virtual void show() const

{cout & lt& lt count & lt _'<<x<< endl}<P>

Protected:

Static integer counting;

Private:

int x;

};

Class d: public B{

Public:

D(int xx,int yy):B(xx),y(YY){ ++ count; y+= 100; }

Virtual void show() const

{cout & lt& lt Count & lt _'<<y<< Endl}<P>

Private:

int y;

};

int B::count = 0;

int main(){

B * ptr = new d D( 10/0,20);

ptr-& gt; show();

Delete ptr

Returns 0;

}

The output of the runtime is

A) 1_ 120

B)2_ 120

C) 1_20

d)2-20

Fill in the blanks (2 points for each blank, 30 points for * * *)

Please write each blank correct answer on the horizontal line of the answer sheet serial number l~ 15, and the answer will not be scored on the test paper.

The initial state of the (1) queue is empty. Now elements A, B, C, D, E, F, 5, 4, 3, 2, 1 are put into the team in turn, and then retired in turn, so the order of element retirement is 1.

(2) Let the capacity of the circular queue be 50. If the head pointer front=45 (pointing to the previous position of the queue head element) and the tail pointer rear= 10 (pointing to the queue tail element), there are 2 elements in the circular queue.

(3) Set the binary tree as follows:

The result of postorder traversal of binary tree is 3.

(4) Software is a collection of data and documents.

(5) There is a relationship between students' course selection, in which the relationship model of students is: students (student number, name, class, age), and the relationship model of courses is: courses (class number, course name, class hours), in which the keywords of two relationship models are student number and class number respectively, so the relationship model of course selection can be defined as: course selection (student number, grade 5).

(6) If X and Y are two integer variables, after executing the statement sequence.

x = 5; y = 6; y+= x-;

After that, the value of x+y is 6.

(7) In the execution of sentence sequence

int I = 0; do i++; while(I * I & lt; 10);

The loop statement i++ after, do is executed 7 times.

(8) has the following function definitions:

int Xfun(int *a,int n){

int x = * a;

for(int * pa = a+ 1; pa & lt& gt

if(* pa & gt; x)x = * pa;

Returns x;

}

If the statement is executed

int x[5]={23,46,78,55, 16 };

Then the function is called by the expression Xfun(x, 5), and the return value is 8.

(9) The following functions are defined:

int Xfun(int x){

int y = x;

{ int x = 10; y+= x; }

Returns x+y;

}

Call this function through the expression Xfun(5), and the return value is 9.

(10) suppose Xcs is a class, and the prototype of a member function in this class is "xcs * ABC ();" When defined outside the class, the corresponding function header is 10.

(1 1) Please complete the definition of the following class date to make it consist of statements.

Date of the first day;

The value of the defined object FirstDay is 20 10 10 1.

Date of class {

Public:

Date (1 1): year (y), month (m), day (d){}

Private:

Int year, month and day; //Represents the year, month and day in turn.

};

(12) Please complete the following program to make the program output "Gone with the Wind is Zhang Na's book".

# Including

Use namespace std

Classroom books {

Public:

Book(char *str) {strcpy(title,str); }

12 void PrintInfo(){ cout & lt; & ltTITLE & lt& ltENDL} & ltp & gt

Protected:

char title[50];

};

Class MyBook:public Book{

Public:

My book (char *s 1, char *s2= "Zhang Na"):

13 {strcpy (owner, S2); }

Virtual void printinfo () {cout <; & ltTITLE & lt& lt is the owner.

Private:

char owner[ 10];

};

int main(){

Book *prt=new MyBook ("Gone with the Wind");

PRT-& gt; PrintInfo();

Returns 0;

}

(13) Overloading Insert Operator

Similarity {

Public:

Rational(int aa,int qq):a(aa),q(qq){ }

Friend 14 Operator & lt& lt(ostream & amp, rational & ampx)

{

Return (out<& ltX. A<& ltp? & lt& ltx . q); & lt& gt

}

Private:

int a,q;

};

(14) The following function definitions are function instances that can be generated by function templates.

int square(int n){ return n * n; }

double square(double n){ return n * n; }

So the definition of this function template is 15.