满意答案
bzkk36
2016.07.28
采纳率:58% 等级:12
已帮助:7250人
#include
#include
#include
int main()
{
char str1[1000] = { 0 }, str2[100] = { 0 }, str3[100] = { 0 };//字符串1串长最大数值为999字节,字符串2、3串长最大数值为99
scanf("%s%s%s", str1,str2,str3);
char temp[100] = { 0 }, temp1[1000] = { 0 }, temp2[1000] = { 0 };
int i = 0, j = 0;
for (i = 0; i
{
int len = i + strlen(str2);
for (j = i; j
{
temp[j - i] = str1[j];
}
if (strcmp(temp, str2) == 0)
{
for (j = 0; j
temp1[j] = str1[j];
for (j = len; j
temp2[j - len] = str1[j];
strcpy(temp, str3);
strcpy(str1, temp1);
strcat(str1, temp);
strcat(str1, temp2);
}
}
printf("%s", str1);
system("pause");
return 0;
}
01分享举报