1300: 实验2-2-3 删除子串的C风格字符串与string实现 / Removing Substrings with C-Style Strings and string

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:157 Solved:140

Description

【中文题面】
从键盘输入两个字符串,两个字符串都可能包含空格。判断第二个字符串是否在第一个字符串中出现。若出现,从左到右扫描第一个字符串。每当当前位置开始能匹配第二个字符串,就删除这一段,然后从这段之后继续扫描;已经被删除的字符不能再参与下一次匹配。若没有出现,则直接输出第一个字符串。
课堂要求:本题在同一个OJ题目中提交两种solution:第一种使用C风格字符串(字符数组或char*)实现,第二种使用string实现。保证第二个字符串非空,匹配区分大小写。
[English Statement]
Input two strings from the keyboard. Both strings may contain spaces. Determine whether the second string appears in the first string. If it appears, possibly multiple times, remove all non-overlapping occurrences of the second string from left to right and output the remaining content. If it does not appear, output the first string directly.
Class requirement: submit two solutions to the same OJ problem. The first solution should use C-style strings (character arrays or char*), and the second should use string. The second string is guaranteed to be non-empty, and matching is case-sensitive.

Input

【输入】
第一行输入第一个字符串。第二行输入第二个字符串。字符串长度不超过1000。
[Input]
The first line contains the first string. The second line contains the second string. The length of each string does not exceed 1000.

Output

【输出】
输出删除后的字符串。若全部删除,则输出空行。
[Output]
Output the resulting string. If all characters are removed, output an empty line.

Sample Input Copy

I like AI and AI helps
AI

Sample Output Copy

I like  and  helps

HINT

C风格版本建议使用cin.getline读入包含空格的字符串,并手写匹配过程。string版本可使用getline和基础成员函数。
For the C-style version, use cin.getline to read strings containing spaces and write the matching logic manually. For the string version, use getline and basic member functions.