I went to Huawei for another interview and added a question for the computer examination.
It was a big surprise for me to regard Huawei interview as a software proficiency test.
Okay. Now let's talk about the computer examination:
1. First, enter your name and mobile phone number on their computer examination page (this is also the first of Huawei s and is convenient for candidates who have excellent scores directly :))
2. download their machine test code. A simple project contains an unimplemented function and function description.
3. You implement this function, debug the program, and then package it into a zip file for upload.
The problem I encountered was as follows:
A character string contains space character characters with random positions. All non-space characters in the character string should be found, and spaces should be replaced.
There must be a ',' At the end of the replaced sentence.
For example, the result after "This Is An Demo" is replaced is:
"This, is, an, demo ,"
Is the question very simple? In fact, there are still many "points" in this question. If you do not think about it at all, your score will be affected.
Now I will introduce the implemented functions:
Void replacestring (char * pinstring, int ileng, char * poutstring) // (poutstring is assumed to be long enough memory and imported from outside)
{
* Poutstring = "/0 ";
While (* pInString = '') // jump space character that occur at start.
PInString ++;
Char * ptOutString = pOutString;
While (* pInStirng)
{
* PtOutString = * pInString;
PtOutString ++;
PInString ++;
If (* pInString = '')
{
* PtOutString = ',';
PtOutString ++;
}
While (* pInString & * pInString = '')
PInString ++;
}
* PtOutString = '/0 ';
If (pOutString [0]! = '/0' & * (ptOutString-1 )! = ',')
{
* PtOutString = ',';
* (++ PtOutString) = '/0 ';
}
}
Well, this is the perfect answer. You can write it yourself and refer to it.