#include<stdio.h>
#include<stdlib.h>
int main()
{
char s[]="I have an apple.Do you like apple?";
char s1[]="apple";
char s2[]="orange";
int i,j,k,h,p,c;
for(p=0;s[p]!='\0';)
p++;
for(i=0;s[i]!='\0';i++)
for(j=i,k=0;s1[k]==s[j];k++,j++)
if(s1[k+1]=='\0')
{
for(i=j-k,h=0;s[i]!='\0'&&s2[h]!='\0';)
{
if(h>k)
{
for(c=p-1;c>=i;c--)
s[c+1]=s[c];
}
s[i++]=s2[h++];
}
break;
}
printf("%s\n",s);
system("pause");
return 0;
}
csdn上别人提的问题,大神,能帮我改改吗?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
8条回答 默认 最新
- 远方的飞猪 2015-12-21 11:14关注
/*#include
#include
char s1[50];
char s2[]={'a','p','p','l','e'};
char s3[]={'o','r','a','n','g','e'};
char target [100];
int i=0,j,count=0;
int main()
{
gets(s1);
while(s1[i]!='\0')
{
if((s1[i]==s2[0])&&(s1[i+1]==s2[1])&&(s1[i+2]==s2[2])&&(s1[i+3]==s2[3])&&(s1[i+4]==s2[4]))
{
for(j=0;j<strlen(s3);j++)
{
target[count]=s3[j];
count++;
}
i=i+5;
}
else
{
target[count]=s1[i];
count++;
i++;
}
}
puts(target);
return 0;
}本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 多址通信方式的抗噪声性能和系统容量对比
- ¥15 winform的chart曲线生成时有凸起
- ¥15 msix packaging tool打包问题
- ¥15 finalshell节点的搭建代码和那个端口代码教程
- ¥15 Centos / PETSc / PETGEM
- ¥15 centos7.9 IPv6端口telnet和端口监控问题
- ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
- ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
- ¥20 海浪数据 南海地区海况数据,波浪数据
- ¥20 软件测试决策法疑问求解答