编程介的小学生 2017-02-18 14:28 采纳率: 20.5%
浏览 873
已采纳

Word Process Machine

It is year 7896 since Christ's birth. Intel Corp. engineers are developing new Pentium XXXIV processor optimized for�� no, not for floating point calculations critical multimedia games but for one strange word processing algorithm. The algorithm accepts a string of characters and produces the result string (which is initially empty) using only two simple processor instructions: GET (removes the first character of the source string and appends one to the end of the result string) and REVERSE (reverses the rest of the source string). Doesn't it looks strange the computer engineering still solves the problems we could solve (couldn't we?) at November the 4th, 2000, 5896 years ago? So, your goal here is to implement that word processing machine. Your program will be given the source string for the algorithm and algorithm itself encoded using those GET and REVERSE commands. The program should print the string which is the result of the application of the given algorithm to the given source string.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Input

First line of the input contains single integer 1 <= N <= 500 - number of lines in an input string (each not longer than 80 characters). Following lines contain data that form an input string (newline characters, but not spaces should be ignored). The rest of the file (not more than 100000 characters) up to # character contains commands of the algorithm coded as the following: G - for GET, R - for REVERSE. The algorithm code can also contain newline and space characters that should be ignored.

Output

The output should contain the result of the algorithm application to the given string printed so that all lines (excluding probably the last one) contain exactly 80 characters.

Sample Input

1

2
ab c
def
RR G
GG RGG#

Sample Output

ab fe

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-02-22 14:18
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!