POJ C + + programming Problem # # # string manipulation

Source: Internet
Author: User

Programming Question # # #: String manipulation

Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )

Note: Total time limit: 1000ms memory limit: 65536kB

Describe

Given n strings (numbered starting at 1), the character positions in each string are numbered from 0, with a length of 1-500, and there are several actions that are available:

Copy n x L: Takes out the string with the length of L for the nth string, starting with the first X character.

Add S1 S2: Determines whether the s1,s2 is an integer between 0-99999, if it is converted to an integer to do addition, if not, then as a string addition, the value returned is a string.

Find S N: finds the S string from the left in the nth string, returns the position where it first appears, and returns the length of the string if it is not found.

RFind s N: Finds the S string in the nth string from the right, returns the position where it first appears, and returns the length of the string if it is not found.

Insert s N x: Inserts an S string in the X-character position of the nth string.

Reset S N: Changes the nth string to S.

Print N: Prints the nth string of output.

Printall: Prints out all strings.

Over: End operation.

Where n,x,l can be composed of find and rfind operation expressions, S,S1,S2 can be composed of copy and add operation expressions.

Input

First behavior an integer n (n between 1-20)

Next n behaves n strings, strings do not contain spaces and operation commands, and so on.

The next several behaviors are followed by a series of actions until over.

Output

Output the corresponding string according to the operation prompts.

Sample input
3329strjvcopadfk48ifjoqwoqejrinsert Copy 1 Find 2 1 2 2 2print 2reset add copy 1 Find 3 1 3 copy 2 find 2 2 2 3print 3inse RT a 3 2printallover
Sample output
Op29adfk48358329strjvcop29adfk4835a8
Tips

It is recommended to use the related operation function in the string class.

This question is very lack of thought, reference this answer http://bailian.openjudge.cn/topic/3534/

First encounter this kind of problem, do more do may be much better, the first time do not have any method

Note that the ITOs function is replaced with the sprintf function, but I don't recognize the ITOs function on my computer.

POJ C + + programming Problem # # # string manipulation

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.