当前位置:网站首页>7-29 delete substring in string (non KMP)
7-29 delete substring in string (non KMP)
2022-06-29 01:31:00 【Big fish】
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 Code :
#include<stdio.h>
#include<string.h>
int main()
{
char s[100];
char a[100];
gets(s);gets(a);// Read array
int i,j,k;
i=0;
int len = strlen(a);// Calculate the length of the array
while(s[i]!='\0')// Traversal array
{
if(s[i]==a[0])
{
int count=0;
for(j=i;j<i+len;j++)
{
if(a[j-i]==s[j]) count++;
}
if(count==len)
{
for(k=i+len;k<strlen(s);k++)
{
s[k-len]=s[k];
}
s[k-len]='\0';
i=0;
}
else i++;
}
else i++;
}
printf("%s",s);
}边栏推荐
- 【Proteus仿真】4x4矩阵键盘中断方式扫描 +数码管显示
- Hello i am back
- 大厂裁员潮下,测试人员路在何方?
- GUI Graphical user interface programming example - color selection box
- Similarities and differences between SRAM and DRAM
- Streaming media cluster application and configuration: how to deploy multiple easycvr on one server?
- 接雨水系列问题
- With this tool, automatic identification and verification code is no longer a problem
- 198. house raiding
- Basic use of flask Sqlalchemy
猜你喜欢

Rasa对话机器人之HelpDesk (五)

Similarities and differences between SRAM and DRAM

TypeScript(4)接口

Installation de la base de données Oracle dans docker

4276. good at C

Day 8 script and audio
![[image detection] recognition of the front and back of a coin based on texture features with matlab code attached](/img/61/1fb15e9defa1fc471c4d2d34cc1ed4.jpg)
[image detection] recognition of the front and back of a coin based on texture features with matlab code attached

Do280 allocating persistent storage

Day 7 scripts and special effects

栈的增删查改---动态内存
随机推荐
What is the reason for the service crash caused by replacing the easycvr cluster version with the old database?
Typescript (7) generic
Magic Quadrant of motianlun's 2021 China Database
How to select database
栈的增删查改---动态内存
牛客网——华为题库(41~50)
Statistical learning method (3/22) k-nearest neighbor method
Large-scale case applications to developing post-click conversion rate estimation with MTL
第七天 脚本与特效
How to use PN junction to measure temperature?
Typescript (6) function
机构加密资产产品上周流出4.23亿美元资金,创历史新高
Exclusive analysis | about resume and interview
3D, point cloud splicing
MySQL realizes data comparison between two tables by calculating intersection and difference sets
[Fire Detection] forest fire detection system based on Matlab GUI (with panel) [including Matlab source code phase 1921]
Basic use of flask Sqlalchemy
Is it safe to open a securities account at qiniu business school in 2022?
Do280 allocating persistent storage
sqlalchemy的基本使用