This is my code, test cases can be, but is not a secret, is there a big help to look at what went wrong, and the problem is how to do,
thank you?
# include & lt; Stdio. H>
Int main ()
{
Char s [100], t [10], STR [10], a [120].
Int count1, count2, count3;
Int n, I, j, x;
for(i=0; i<100; I++)
{
The scanf (" % c ", & amp; S [I]);
[I] if (s=='\ n')
{
break;
}
} count1=I;//s [] array element number count1
for(i=0; i<10; I++)
{
The scanf (" % c ", & amp; [I] t);
If (t [I]=='\ n')
{
break;
}
} count2=I;//t [] array element number count2
for(i=0; i<10; I++)
{
The scanf (" % c ", & amp; STR [I]);
If (STR [I]=='\ n')
{
break;
}
} count3=I;//array STR [] element number count3
Int w=1;
H: w++;//return to its original position
For (I=w; i<100; I++)
{
If (s==[I] t [0])//the subscript for equal I
{
break;
}
} int p=0;
For (j=I; J<100; J++)
{
If (s==t [p] [j])//the subscript range for j
{
p++;
} the else
{
break;
}
}
If (j - I==count2)//determine whether to be the replacement string
{
For (n=0; N{
[n] a [n]=s;
}
For (n=I; N
A [n]=STR [x];
}
For (n=count3 + I; N
A [n]=s [j];
}
If (count1 count2 + count3 & lt;
=100){
For (n=0; N
Printf (" % c ", a [n]);
}
printf("\n");
} the else
{
For (n=0; N<100; N++)
{
Printf (" % c ", a [n]);
}
printf("\n");
}
} the else
{
Goto h;
}
}
CodePudding user response:
Reference:# include & lt; Stdio. H>
Int main (int arg c, char * argv [])
{
Char * s=new char [100], * t=new char [10], * STR=new char [10], * temp=new char [100].
Char * p, * q * pos;
Gets (s);
Gets (t);
gets(str);
P=s;
Q=temp;
While (* p!='\ 0')
{
Pos=STR;
If (* p==* t) {
While (* p==* t & amp; & * t!='\ 0') {
p++;
t++;
}
While (* pos!='\ 0') {
* q++=* pos++;
}
}
* q=* p;
Q++;
p++;
}
* q='\ 0';
Strcpy (s, temp);
Printf (" % s \ n ", s);
system("pause");
return 0;
}