当前位置:网站首页>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;
}
边栏推荐
- Chapter 1: cross end development of small programs of uniapp ----- create a uniapp project
- ogg里用多个filter语法应该怎么写?
- 试题 历届试题 发现环
- Pl/sql server syntax explanation
- 中兴通讯:5nm 5G基站芯片正在技术导入!
- It is said that the global semiconductor equipment giant may build a joint venture factory in Shanghai!
- C语言 二级指针详解及示例代码
- 第11届蓝桥杯本科组校赛(20200321)
- Qt生成.exe文件 并 在无Qt环境下运行(Enigma Virtual Box进行绿色可执行软件封装)图文教程
- 配置树莓派,过程和遇到问题
猜你喜欢

QT generation Exe file and run without QT environment (enigma virtual box for green executable software packaging) graphic tutorial

14. Double pointer - the container that holds the most water

利用正则表达式从文件路径中匹配文件名

数据库安全 --- 创建登录名 用户+配置权限【笔记】

django-celery-redis异步发邮件

AP Autosar平台设计 1-2 导言、技术范围与方法

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

Qt生成.exe文件 并 在无Qt环境下运行(Enigma Virtual Box进行绿色可执行软件封装)图文教程

配置树莓派,过程和遇到问题

Uni app project directory, file function introduction and development specification
随机推荐
Summary of key points of bank entry examination
Troubleshooting of tool failure caused by Chinese characters in PT kill query
集群为什么需要root权限
Multithreading and high concurrency (III) -- source code analysis AQS principle
多线程与高并发(三)—— 源码解析 AQS 原理
SQL Server 2016 learning records - single table query
3. Print the linked list in reverse order with the array
AP Autosar平台设计 3架构
Alibaba cloud image address
2021-10-13arx
吴雄昂遭Arm罢免内幕:建私人投资公司,损害了股东利益?
逆元&组合数&快速幂
Codeforces Round #614 (Div. 2) B. JOE is on TV!
Step 4 - user development environment settings
16. String inversion
IDEA创建我的第一个项目
Small knowledge in Oracle
Inside story of Wu xiongang being dismissed by arm: did the establishment of a private investment company harm the interests of shareholders?
string matching
[wechat applet] project practice - lottery application