#include<iostream> #include<stdio.h> #include<string> #include<cstring> #include<algorithm> #include<vector> #include<queue> #include<map> #define INF 0x3f3f3f using namespace std; void rep(char str[],char key[],char swa[]) { int len1,len2,len3,i,j,flag; char tmp[505]; len1=strlen(str); len2=strlen(key); len3=strlen(swa); for(i=0;i<=len1-len2;i++) { flag=1; for(j=0;j<len2;j++) if(str[i+j]!=key[j]) { flag=0; break; } if(flag) { strcpy(tmp,str); strcpy(&tmp[i],swa); strcpy(&tmp[i+len3],&str[i+len2]); strcpy(str,tmp); i+=len3-1; len1=strlen(str); } } } int main() { int n; char S[505],A[505],B[505]; scanf("%d",&n); while(n--) { scanf("%s",S); scanf("%s",B); scanf("%s",A); rep(S,B,A); printf("%s\n",S); } } |
Double click to view unformatted code.