From: http://blog.163.com/softwaredep@126/blog/static/474112722007102593541438/
Output
Char S1 [] = "2 kgames ";
Char * S2 [] = {"2 kgames "};
Char S3 [20] = "2 kgames ";
Sizeof (S1) =?
Sizeof (S2) =?
Sizeof (S3) =?
Strlen (S1) =?
Strlen (S3) =?
<Answer: 8 4 20 7 7
2. Output
Class
{
Public:
A () {P ();}
~ A () {P ();}
Virtual void P () {q ();}
Virtual void Q () {cout <''a ''}
};
Class B: public
{
Public:
B () {P ();}
~ B () {P ();}
Void Q () {cout <'B ''}
};
Int main ()
{
A * P = new B;
Delete P;
}
Answer: ABA
3. Use a c expression to determine whether a number is the N power of 2.
Answer: x = (x ^ (~ 0x0) + 1) & X)
4. Write a high-performance function to multiply an int by 9
Answer:
Int multiply_9 (int)
{
Return (A <3) + );
}
5. Write a C function. If the processor is big_endian, 0 is returned. If the processor is little_endian, 1 is returned.
Answer:
Int checkcpu ()
{
Union W
{
Int;
Char B;
} C;
C. A = 1;
Return (C. B = 1 );
}
6. INT (* f) (INT, INT) (INT) What is f here?
Answer: F is a pointer pointing to a function with the (INT, INT) parameter and the return value is a pointer.
The returned Pointer Points to a function with the (INT) parameter and the return value is int.
My written test II: Cisco
1.
Typedef struct
{
Char data [10];
} T1;
Typedef struct
{
T1 * P;
Char data [0];
} T2;
Sizeof (T2) =?
Answer: 4
2. An array containing n elements. The value range of the array is 1 ~ N-1 to find the repeated value.
Answer:
Int array [N];
Int findrepeat (void)
{
Int flag [N] = {0 };
Int I;
For (I = 0; I less than N; I ++) // the error message returned when the system of this forum is abnormal due to a problem in the system of this forum.
{
If (flag [array [I] = 1)
Return array [I];
Else
Flag [array [I] = 1;
}
}
3. Which of the following cannot be translated?
().
Void T ()
{
Const int n= 100;
Int A [n];
A [2] = 42;
}
(B ).
Void T ()
{
* (Int * const) 0x23567890) = 5;
}
(C ).
Char * FUC (void)
{
Char A [4];
Strcpy (a, "ABCD ");
Return;
}
Answer: ABC can all be compiled.
My written test article 3: Trend Micro
1. Incorrect search
(1) void test (const int V)
{
Int * P;
P = V;
}
Answer: The non-const pointer cannot be directed to the const variable. It should be: const int * P;
(2) void test (const Int & V)
{
Const Int & P;
P = V;
}
Answer: The reference must be initialized during definition. It should be: const Int & P = V;
2. programming questions: Flip the linked list.
Answer:
Typedef struct Node
{
Int value;
Struct node * next;
} Slink;
Slink * reverselink (slink * H)
{
Slink * Pre, * cur, * next;
Pre = NULL;
Cur = h;
Next = cur-> next;
While (next)
{
Cur-> next = pre;
Pre = cur;
Cur = next;
Next = Next-> next;
}
Return cur;
}
3. Write output results
Class
{
Public:
A ()
{
F (0 );
}
Virtual void F (int n)
{
Cout <"A0:" <}
Virtual void F (int n) const
{
Cout <"A1:" <}
Virtual void F (char * s)
{
Cout <"A2:" <}
};
Class B: public
{
Public:
Void F (int n)
{
Cout <"B0:" <}
Void F (char * s)
{
Cout <"B1: <}
};
Int main ()
{
A * P;
Const A * CP;
B;
P = & B;
P-> F (1 );
P-> F ("test ");
A (). F (2 );
CP = & B;
CP-> F (2 );
}
Answer:
A0: 0
B0: 1
B1: Test
A0: 0
A0: 2
A1: 2
4. What is the transmission distance of UTP (unshielded twisted pair wires?
Answer: 100 m
The subnet mask of 5.176.68.160.0/22 is:
Answer: 255.255.252.0
My Written Test 4: Pioneer Shang Tai
1. Which of the following statements is true:
A. char * const S = "hello ";
* S = ''' w ''''
B. char * const S = "hello ";
S = "world ";
C. Const char * s = "hello ";
* S = ''' w ''''
D. Const char * s = "hello ";
S = "world ";
Answer: d
2. Which of the following statements is true:
A. char * const S = "hello ";
* S = ''' w ''''
B. char * const S = "hello ";
S = "world ";
C. Char s [] = "hello ";
* S = ''' w ''''
D. Char s [] = "hello ";
S = "world ";
Answer: c
3. Write the program output result:
Char T [] = "abcdefghijklmno ";
T [12] = ''/0'' // there shouldn't be so many single quotes
Int I = 0;
While (T [++ I]! = ''/0'') // here is also
{
Printf ("% C", t [I ++]);
}
Answer: bdfhjln
My Test 5-Zhan Xun
1. Calculate the maximum public string of two strings programmatically.
Answer:
# Include "stdio. H"
# Include "string. H"
/* Function: calculate the maximum public string of two strings */
Void commonstr (char * str1, char * str2)
{
Char * S1, * S2;
Int I, j, k; // I -- maximum length of a Public String
Int len1; // J -- start position of the substring S2
Int len2; // K -- start position of the substring S1
Int P;
Len1 = strlen (str1 );
Len2 = strlen (str2 );
If (len1
{
S1 = str2;
S2 = str1;
Len2 = len1;
}
Else
{
S1 = str1;
S2 = str2;
}
For (I = len2; I> 0; I --) // start from the largest
{
For (j = 0; j + I <= len2; j ++)
{
For (k = 0; k + I <= len1; k ++)
{
P = 0;
While (S1 [K + P] = S2 [J + P])
{
P ++;
}
If (P> = I)
{
For (P = 0; P is smaller than I; P ++)
Printf ("% C", S1 [K + P]);
Printf ("/N ");
Return;
}
}
}
}
}
Int main (void)
{
Char * S1 = "worlld ";
Char * S2 = "Hello, cjw ";
Commonstr (S1, S2 );
Return 0;
}
2. Calculate the number of 1 bytes.
Method 1:
Int num_1 (char data)
{
Int I, J;
Int sum = 0;
J = 1;
For (I = 0; I <8; I ++)
{
J = 1 <
If (Data & J)
Sum ++;
}
Return sum;
}
Method 2:
Unsigned int findoneinnumber_02 (unsigned char X)
{
Unsigned int N;
For (n = 0; X; n ++)
X & = X-1;
Return N;
}