把字符串s换为st (s-->st)
code:
#include<bits/stdc++.h>
using namespace std;
char s[1005]="scanf" ;
char st[1005]="printf";
char store[1005];
int main()
{
char a[100005];
while(gets(a))
{
//memset(store,0,sizeof(store));
int p;
int pos;
int l=strlen(a);
int i,j;
for(i=0;i<l;i++)
{
p=0;
if(a[i]=='s')//查找st的第一个字符
{
pos=i;
for(j=pos;j<=strlen(s)-1+pos;j++)
{
store[p]=a[j];
p++;
}
}
if(strcmp(store,s)==0)
{
cout<<st;
i+=(strlen(s)-1);
}
else
{
cout<<a[i];
}
memset(store,0,sizeof(store));
}
cout<<endl;
}
return 0;
} //把s替换为st s-->st