Source code for submission s792

bugs.c

  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int i, j, T, pos;
  5. char B[1005], c;
  6. while(scanf("%d %s", &T, B) != EOF) {
  7. for (i=0; i<T; ++i) {
  8. pos = 0;
  9. while ((c = getchar()) != '\n') {
  10. if (c == B[pos])
  11. ++pos;
  12. else {
  13. if (pos != 0) {
  14. for(j=0; j<pos; ++j)
  15. putchar(B[j]);
  16. pos = 0;
  17. }
  18.  
  19. if (c == B[pos])
  20. ++pos;
  21. else
  22. putchar(c);
  23. }
  24.  
  25. if (B[pos]=='\0')
  26. pos = 0;
  27. }
  28. putchar('\n');
  29. }
  30. }
  31.  
  32. return 0;
  33. }
  34.