开始 2022-10-01 00:00:00

C++语法小测

结束 2022-12-31 00:00:00
Contest is over.
当前 2024-09-08 10:57:49

G. 字符串编辑

描述

从键盘输入一个字符串(长度<=40个字符),并以字符 '.'结束。

例如:'This is a book.' 现对该字符串进行编辑,编辑功能有:

D:删除一个字符,命令的方式为:

     D a  其中a为被删除的字符

     例如:D s  表示删除字符 's' ,若字符串中有多个 's',则删除第一次出现的。

              如上例中删除的结果为: 'Thi is a book.'


<span>I</span>:插入一个字符,命令的格式为:<span></span> 

<span>&nbsp;&nbsp;&nbsp; I a1 a2&nbsp; </span>其中<span>a1</span>表示插入到指定字符前面,<span>a2</span>表示将要插入的字符。<span></span> 

&nbsp; &nbsp; 例如:<span>I s d&nbsp; </span>表示在指定字符<span>&nbsp;'s'&nbsp;</span>的前面插入字符 '<span>d'&nbsp;</span>,若原串中有多个<span>&nbsp;'s'&nbsp;</span>,则插入在最后一个字符的前面。

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;如上例中:<span><br />

                   原串:'This is a book.'

<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>插入后:'<span>This ids a book.'</span> 

<span>&nbsp;</span> 

<span>R</span>:替换一个字符,命令格式为:<span></span> 

&nbsp; &nbsp; &nbsp;R a1 a2&nbsp; 其中a1为被替换的字符,a2为替换的字符,若在原串中有多个a1则应全部替换。

&nbsp; &nbsp; &nbsp;例如:

原串: 'This is a book.'

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;输入命令:<span>R o e</span> 

<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span>替换后的字符串为:<span>'This is a beek.'</span> 

<span><br />

在编辑过程中,若出现被改的字符不存在时,则给出提示信息"Not exist"。

<br />

输入

每个测试文件只包含一组测试数据,每组输入数据包含两行:

第一行,输入一个字符串,表示原串;

第二行,输入一个字符串,表示命令。


输出

对于每组输入数据,输出编辑后的字符串,如果被改的字符不存在,则输出"Not exist"(引号不输出)。


样例

输入

This is a book.
D s

输出

Thi is a book.

提示

This is a book.

I s d

			<div>
				<br />
			</div>


		</td>
		<td>
			This ids a book.<br />



		</td>
	</tr>
	<tr>
		<td>
			<span>This is a book.</span><br />

R o e

		</td>
		<td>
			<span>This is a beek.</span><br />
		</td>
	</tr>
	<tr>
		<td>
			<br />
		</td>
		<td>
			<br />
		</td>
	</tr>
</tbody>



Submit

登录

注册
时间限制 1 秒
内存限制 125 MB
提交