当前位置:网站首页>20200229 training match L1 - 2 delete the substring in the string (20 points)
20200229 training match L1 - 2 delete the substring in the string (20 points)
2022-07-28 10:33:00 【Xiaoliu xuezha】
Input 2 A string S1 and S2, Request to delete string S1 All substrings that appear in S2, That is, the result string cannot contain S2.
Input format :
Enter in 2 No more than... Are given in each line 80 In characters 、 End with carriage return 2 Non empty strings , Corresponding S1 and S2.
Output format :
Output the deletion string in one line S1 All substrings that appear in S2 Result string after .
sample input :
Tomcat is a male ccatat
cat
sample output :
Tom is a male
- find(string s) Return string s Starting subscript of the first occurrence , No return found string::npos
- erase(a,b) from a The subscript begins to be deleted , The deletion length is b
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a,b;
getline(cin,a);
getline(cin,b);
while(a.find(b)!=string::npos)
{
a.erase(a.find(b),b.length());
}
cout<<a;
return 0;
}
边栏推荐
- How to write Ogg with multiple filter syntax?
- ogg里用多个filter语法应该怎么写?
- Django celery redis send email asynchronously
- 逆元&组合数&快速幂
- Continue to write the greatest work based on modelarts [play with Huawei cloud]
- 按位与、或、异或等运算方法
- 机器人技术(RoboCup 2D)如何进行一场球赛
- SQL Server 2016 学习记录 ---视图
- 中兴通讯:5nm 5G基站芯片正在技术导入!
- 上下文变量值(context values)陷阱及在 Go 中如何避免或缓和这些陷阱
猜你喜欢

机器人技术(RoboCup 2D)如何进行一场球赛

SQL Server 2016 learning records - data update

6. Double pointer -- the sum of the two numbers of the incremental array is equal to the target number

逆元&组合数&快速幂

ACM winter vacation training 5

CentOS7下安装mysql5.7

数据库安全 --- 创建登录名 用户+配置权限【笔记】
![[application of stack] - infix expression to suffix expression](/img/c1/879716342f6dd5eaa8b79c752eca16.png)
[application of stack] - infix expression to suffix expression

Typora使用教程

Qt生成.exe文件 并 在无Qt环境下运行(Enigma Virtual Box进行绿色可执行软件封装)图文教程
随机推荐
10. The penultimate node in the linked list
多线程与高并发(三)—— 源码解析 AQS 原理
Multithreading and high concurrency (III) -- source code analysis AQS principle
MySQL的SQL TRACE一例
问题总结档案
6. Double pointer -- the sum of the two numbers of the incremental array is equal to the target number
Detailed explanation of super complete knowledge points of instruction system
【栈的应用】--- 中缀表达式转后缀表达式
SQL Server 2016 learning records - single table query
11. Linked list inversion
11、链表反转
Inverse element & combinatorial number & fast power
Pl/sql server syntax explanation
在mt6735中添加新的开机logo与开\关机动画
机器学习--手写英文字母3--工程特点
SQL Server 2016 learning records - View
Bitwise and, or, XOR and other operation methods
ACM寒假集训#5
Qt生成.exe文件 并 在无Qt环境下运行(Enigma Virtual Box进行绿色可执行软件封装)图文教程
ACM winter vacation training 5