2014 questions about Huawei campus recruitment Machine

Source: Internet
Author: User

The machine questions for Huawei 2014 campus recruitment are exactly the same as those for 2013.
I. Question description (60 points ):
Enter a string of lowercase letters (~ Z. Compile a character string filter program. If multiple identical characters appear in the string, filter out non-first-time characters.
For example, the "abacacde" character string is "abcde ".

Required implementation function: void stringFilter (const char * pInputStr, long lInputLen, char * pOutputStr );

[Input] pInputStr: input string
LInputLen: length of the input string
[Output] pOutputStr: Output string. The space has been opened up and the length of the input string is equal to that of the input string;

[Note] You only need to complete the function algorithm, and there is no IO input or output in the middle.

Example
Input: "deefd" output: "def"
Input: "afafaf" output: "af"
Input: "pppppppp" output: "p"

The main function has been hidden. This is the test entry reserved for users. Here, you can test your implementation function and call printf to print the output.
Currently, you can use other methods to test the function. You only need to ensure that the final program can be correctly executed. The function implementation can be modified without changing the function prototype. Make sure that compilation and running are not affected.
 
Ii. Question description (40 points ):
Enter a string of lowercase letters (~ Z. Compile a character string compression program to compress duplicate letters that are present continuously in the string and output the compressed character string.
Compression rules:
1. Only compress the repeated characters. For example, the compressed string "abcbc" is still "abcbc" because there are no consecutive duplicate characters ".
2. The format of the compressed field is "repeated characters + characters ". For example, after the string "xxxyyyyz" is compressed, it becomes "3x6yz ".

Required implementation functions:
Void stringZip (const char * pInputStr, long lInputLen, char * pOutputStr );

[Input] pInputStr: input string
LInputLen: length of the input string
[Output] pOutputStr: Output string. The space has been opened up and the length of the input string is equal to that of the input string;

[Note] You only need to complete the function algorithm, and there is no IO input or output in the middle.

Example
Input: "cccddecc" output: "3c2de2c"
Input: "adef" output: "adef"
Input: "pppppppp" output: "8 P"

Next, let's take a look at the highlights of page 2nd:

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.