当前位置:网站首页>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);
}边栏推荐
猜你喜欢

免疫组化和免疫组学之间的区别是啥?

Installing Oracle database in docker

Finally understand the difference between DOM XSS and reflection XSS

【温度检测】基于matlab GUI热红外图像温度检测系统【含Matlab源码 1920期】

How can multidimensional analysis pre summary work?

The metadata request parsing principle of OData XML format applied by SAP ui5 is based on domparser

How to use PN junction to measure temperature?

Test a CSDN free download software

独家分析 | 软件测试关于简历和面试的真实情况

第八天 脚本与音频
随机推荐
[temperature detection] thermal infrared image temperature detection system based on Matlab GUI [including Matlab source code 1920]
Flask-SQLAlchemy的基本使用
After easycvr creates a new user, the video access page cannot be clicked. Fix the problem
I want to buy stocks today, OK? Is it safe to open an account online now?
IPFS简述
What is the reason for the service crash caused by replacing the easycvr cluster version with the old database?
[image processing] image curve adjustment system based on MATLAB
[proteus simulation] 4x4 matrix keyboard interrupt mode scanning + nixie tube display
【RRT三维路径规划】基于matlab快速扩展随机树无人机三维路径规划【含Matlab源码 1914期】
一种全面屏手势适配方案
How to solve the problem of Caton screen when easycvr plays video?
Esmm reading notes
华泰证券安全吗
Misunderstanding of innovation by enterprise and it leaders
With this tool, automatic identification and verification code is no longer a problem
IPFs Brief
Magic Quadrant of motianlun's 2021 China Database
Mysql database password modification
Interviewer: with the for loop, why do you need foreach??
免疫组化和免疫组学之间的区别是啥?