Advertisement
palmerstone

Automatic Editing

Jul 19th, 2011
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <math.h>
  5. #include <string.h>
  6. #define EPS 1e-8
  7. #define pi 3.1415926535897932384626433832795028841971693993751
  8. #define N 2147483647
  9.  
  10. int t, i, j, k, l, a, b, c, d, x, y, z, flag, flag2, len, len2, n, m, p;
  11. char ch, str[1000][1000], str2[1000][1000], str3[10000], str4[10000], str5[10000];
  12. char *ptr, *pch;
  13.  
  14. int main()
  15. {
  16. /*freopen("sample.txt", "r", stdin);*/
  17. for (; ;)
  18. {
  19. scanf("%d", &n);
  20. scanf("%c", &ch);
  21. if (n == 0) break;
  22. for (j = 0; j < n; j++)
  23. {
  24. gets(str[j]);
  25. gets(str2[j]);
  26. }
  27. gets(str4);
  28.  
  29. for (j = 0; j < n;)
  30. {
  31. pch = strstr(str4, str[j]);
  32. if (pch != '\0')
  33. {
  34. l = 0;
  35. for (ptr = str4; ptr < pch; ptr++)
  36. {
  37. str3[l] = *ptr;
  38. l++;
  39. }
  40.  
  41. len = strlen(str2[j]);
  42. for (k = 0; k < len; k++)
  43. {
  44. str3[l] = str2[j][k];
  45. l++;
  46. }
  47. len = strlen(str[j]);
  48. for (ptr = pch + len; *ptr != '\0'; ptr++)
  49. {
  50. str3[l] = *ptr;
  51. l++;
  52. }
  53. str3[l] = '\0';
  54. strcpy(str4, str3);
  55. }
  56. else
  57. {
  58. j++;
  59. }
  60. }
  61. printf("%s\n", str4);
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement