The character string compression program compresses duplicate letters in the character string and outputs

Source: Internet
Author: User
Four-legged cat: enter a string of lowercase letters on the keyboard (~ Z. Compile a character string compression program to compress duplicate letters in the character string and output the compressed character string. Compression rules: (1) only compress the repeated characters. For example, the string "abcbc" has no consecutive duplicates.

Four-legged cat: enter a string of lowercase letters on the keyboard (~ Z. Compile a character string compression program to compress duplicate letters in the character string and output the compressed character string. Compression rules: (1) only compress repeated characters. For example, the string "abcbc" has no consecutive duplicates.

Four-legged cat: enter a string of lowercase letters on the keyboard (~ Z. Compile a string compression program,
Compress duplicate letters in the string and output the compressed string.
Compression rules:
(1) only compress the repeated characters. For example, the compressed string "abcbc" is still "abcbc" because there are no consecutive repeated characters ".
(2) The format of the compressed field is "character + number of repeated characters ". For example, the string "xxxyyyyyyz" becomes "x3y6z" after compression ".
(3) do not compress a single character. For example, "abc", after compression or "abc ". <无>
  "; $ Str = str_compress ($ str); echo $ str; echo"
  "; $ Str = str_compress ($ str, 0); echo $ str; echo"
  "; If ($ str = $ old_str) {echo 1;} else {echo 0 ;}

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.