当前位置:网站首页>20200229训练赛 L1 - 2 删除字符串中的子串 (20分)
20200229训练赛 L1 - 2 删除字符串中的子串 (20分)
2022-07-28 10:15:00 【小柳学渣】
输入2个字符串S1和S2,要求删除字符串S1中出现的所有子串S2,即结果字符串中不能包含S2。
输入格式:
输入在2行中分别给出不超过80个字符长度的、以回车结束的2个非空字符串,对应S1和S2。
输出格式:
在一行中输出删除字符串S1中出现的所有子串S2后的结果字符串。
输入样例:
Tomcat is a male ccatat
cat
输出样例:
Tom is a male
- find(string s)返回字符串s第一次出现的开始下标,找不到返回string::npos
- erase(a,b)从a下标开始删除,删除长度为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;
}
边栏推荐
- ACM寒假集训#7
- select如果不加order by子句,返回结果的顺序是不可靠的
- SQL Server 2016 learning records - connection query
- centos7下安装mysql,网上文章都不太准
- 剑指offer
- PHP generates QR code (learning)
- jvm原理
- Summary of key points of bank entry examination
- 4. Adjust the array order so that odd numbers precede even numbers
- SQL Server 2016 学习记录 --- 集合查询
猜你喜欢

SQL Server 2016 learning record - Data Definition

SQL Server 2016 学习记录 --- 数据定义

【栈的应用】--- 中缀表达式转后缀表达式

Get to know SuperMap idesktop for the first time

SQL Server 2016学习记录 --- 连接查询

Record a parent-child project in idea, modify the name of project and module, and test it personally!

多线程与高并发(三)—— 源码解析 AQS 原理

Match file names from file paths using regular expressions

逆元&组合数&快速幂

gcc: error trying to exec 'as': execvp: No such file or directory
随机推荐
Uni app advanced life cycle
Go json.Decoder Considered Harmful
(1) Summary of machine learning concepts
IDEA创建我的第一个项目
Leetcode -- minimum number of rotation array
Netease written test No. 2 -- typical application of European distance
Etcd (highly available kV database)
8. Numbers that appear more than half of the time in the array
初识SuperMap iDesktop
11、链表反转
Huawei takes a 10% stake in fullerene technology, a graphene material manufacturer
死锁算法:银行家算法和安全性算法
[cloud based co creation] Huawei cloud: metastudio digital content production line, which seamlessly integrates the virtual world with the real world
14. Double pointer - the container that holds the most water
吴雄昂遭Arm罢免内幕:建私人投资公司,损害了股东利益?
传全球半导体设备巨头或将于上海建合资工厂!
Small knowledge in Oracle
Bitwise and, or, XOR and other operation methods
Xu Ziyang, President of ZTE: 5nm chip will be launched in 2021
Skillfully use NGX_ Lua makes traffic grouping