Algorithm training string Editing

Source: Internet
Author: User
algorithm training string editing time limit: 1.0s memory limit: 512.0MBThe problem description enters a string (length of <=40 characters) from the keyboard and ends with the character '. '. The editing functions are: 1 D: Delete a character, the command is: D A is a deleted character, for example: D s means the deletion of the character ' s ', if there are multiple ' s ' in the string, then delete the first occurrence.
2 I: Insert a character, the format of the command is: I A1 A2 where A1 is inserted before the specified character, A2 represents the character that will be inserted. For example: I s D means that the character ' d ' is inserted before the specified character ' s ', and there are multiple ' s ' in the Wakahara string, then inserted in front of the last character.
3 R: Replace a character, the command format is: R A1 A2 where A1 is the substituted character, A2 is the replacement character, if there is more than one A1 in the original string should replace all.
In the process of editing, if a changed character does not exist, a prompt message is given. Input format input file stringedit.in A total of two lines, the first behavior of the original string (with '. ' End), the second behavior command (see "Problem description" in the input mode.) Output format output file Stringedit.out A total of one line, for the modified string or output specifies that the character does not exist prompt information. The sample input is a book.
D s sample Output Thi is a book.
D s input and Output sample interpretation command to delete s, the first occurrence in the character s in this, the result is obtained.

Algorithm training string Editing

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.