当前位置:网站首页>Niuke brush questions part6

Niuke brush questions part6

2022-06-11 18:29:00 HHYX.

Niu Ke brush questions

  1. Decimal variables i The value of is 100, So octal variables i The value of is :(C)
    A 146
    B 148
    C 144
    D 142

The question asks 10 Turn into the system 8 Base number , Here the transformation mode and 10 Turn into the system 2 Base is similar to , take 10 Hexadecimal digits are divided by 8 Quotient for each bit , The final result is 144, choice C

  1. The output after executing the following statement is (A)
int I=1;
if(I<=0)
printf("****\n") ;
else
printf("%%%%\n");

A %%
B ****
C There is a grammatical error , Cannot execute correctly
D %%%%

What is used here is printf Format to print , for example %d Print as integer ,%f Print as floating point numbers , The format string has certain rules ,% After that, you need to keep up with specific characters to format and print , If the following is an invalid meaning , It will output directly % Later content . Two consecutive % Will print out a %, So choose A

  1. For the following C One of the things that language statements describe correctly is (C)
    char (*p)[16]
    A p It's a length of 16 Character pointer array of
    B p Is included 16 Character string
    C p Yes, the pointing length is 16 Pointer to the character array of
    D p It's a length of 16 Array of characters

here p stay () Neixianhe * combination , representative p It's a pointer , And then [] representative p The pointer points to a length of 16 Character array of , therefore C The options are right

  1. Array a The definition statement of is “float a[3][4];”, The following () Is an incorrect reference method to an array element .(D)
    A a[i][j]
    B *(a[i]+j)
    C ((a+i)+j)
    D (a+i4+j)

There are two ways to access arrays : One is to use [] How to access by subscribing , The other is send use finger The needle namely *(a+i) Access the contents of the array . Here you need to access a two-dimensional array . Dereference a two-dimensional array or use [] What you access is actually a one-dimensional array , Want to access an element in the array , It needs to be done again [] Or dereference to access , here ABC All meet the conditions ,D Not satisfied, so I choose D

  1. The output of the following program is __________.(D)
#include < iostream.h>
#define SQR(A) A*A
void main() {
    
int x=6,y=3,z=2;
x/=SQR(y+z)/SQR(y+z);
cout< < x< < endl;
}

A 5
B 6
C 1
D 0

In this question, we examine the use of macros . During program compilation , Macro expansion will be performed in the preprocessing stage , The macro will be directly replaced by the content it represents, that is A*A This is replaced by

x/=y+z*y+z/y+z*y+z

The result of the numerical operation carried in is :0 So choose D

  1. When n=5 when , The return value of the following function is :
int foo(int n){
    
if(n<2){
    
return n;
}
else
return 2*foo(n-1)+foo(n-2);
}

A 5
B 11
C 29
D 10

This question examines the understanding of recursive functions , The return condition of recursion is when n<2 Return when , take n=5 Nested recursion begins to unfold , The final result is 29 So choose C

  1. The following for C Linguistic ” The pointer “ What's wrong with the description is :(D)
    A 32 The length of any type of pointer in a bit system is 4 Bytes
    B The data type of the pointer declares the data type that the pointer actually points to the content
    C A wild pointer is a pointer to an unallocated or freed memory address
    D When using free After releasing a pointer content , The value of the pointer variable is set to NULL

In question ,D Option when used free After releasing the contents of the pointer, he will only p The space pointed to is freed and the pointer is not set to null , Avoid setting the pointer to null manually , So choose D

  1. Array is defined as ”int a[4][5];”, quote ”*(a+1)+2″ Express ()( From 0 OK, let's start ) (B)
    A a[1][0]+2
    B a Array number 1 Xing di 2 The address of the column element
    C a[0][1]+2
    D a Array number 1 Xing di 2 Value of column element

Each element in the two-dimensional array in the question is actually a one-dimensional array , therefore (a+1) Represents an array a The address of the first element in the .*(a+1) Represents the first element , It's a one-dimensional array , therefore *(a+1)+2 Express a The address of the element in the first row and the second column of the array , So choose B

  1. There's a structure like this :(A)
struct A{
    
long a1;
short a2;
int a3;
int *a4;
}

Excuse me at 64 Bit compiler sizeof(struct A) What's the calculated size ?
A 24
B 28
C 16
D 18

Calculate the size of the structure , Pay attention to it 64 Bit compiler environment , Therefore, the default alignment number is 8, The pointer size is also 8. Therefore, the calculation rules are based on the size of the structure :size = 4 + 2 + 4 + 2 + 8 + 4 = 24 So choose A

  1. The result of the operation is ?(D)
#include <iostream>
using namespace std;
int f(int n){
    
if (n==1)
return 1;
else
return (f(n-1)+n*n*n);
}
int main(){
    
int s=f(3);
cout<<s<<endl;
return 0;
}

A 8
B 9
C 27
D 36

The operation of recursive program is investigated in the question , Observe that the recursive exit condition is n be equal to 1 Recursively exit when , The value returned each time is n Add n The third power of , That is to say 1 + 2^3 + 3^3 =36 So the final result is D

原网站

版权声明
本文为[HHYX.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111814367537.html