UVA10115 - Automatic Editing
纠结了 两天的一道题 由于字符串函数没用对 就一直做不对 搜了下解题报告 终于知道该怎么用了。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include<string.h> 4 typedef struct node 5 { 6 char c1[100],c2[100]; 7 }st; 8 int main() 9 { 10 int n,t,i,j,k1,k2,m,g,f,y,flag,k; 11 char str[500],*ptr,d[500]; 12 st a[50]; 13 while(scanf("%d%*c",&t)&&t) 14 { 15 for(i = 1 ; i <= t ; i++) 16 { 17 gets(a[i].c1); 18 gets(a[i].c2); 19 } 20 gets(str); 21 for(i = 1 ; i <= t ; i++) 22 { 23 if(strstr(str,a[i].c1)!=NULL) 24 { 25 ptr = strstr(str,a[i].c1) ; 26 k = strlen(a[i].c1); 27 strcpy(d,ptr+k); 28 *ptr = '\0'; 29 strcat(str,a[i].c2); 30 strcat(str,d); 31 i--; 32 } 33 } 34 puts(str); 35 } 36 return 0; 37 }