fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char stack[1000001], str[1000001];
  5. int top = 0;
  6.  
  7. int main() {
  8. int a, len, last, exlen, b, tf, minus;
  9. char ex[37];
  10.  
  11. scanf("%s", str);
  12. scanf("%s", ex);
  13. len = strlen(str);
  14. exlen = strlen(ex);
  15. minus = exlen - 1;
  16. last = ex[minus];
  17.  
  18. for (a = 0; a < len; a++) {
  19. stack[top] = str[a];
  20. top++;
  21. tf = 1;
  22. if (last == stack[top-1] && len >= exlen) {
  23. if (exlen == 1) {
  24. top--;
  25. }
  26. else {
  27. for (int b = 0; b < exlen; b++) {
  28. if (stack[top - 2 - b] == ex[minus-1-b]) {
  29. tf++;
  30. }
  31. }
  32. if (tf == exlen) {
  33. top -= exlen;
  34. }
  35. }
  36. }
  37. }
  38.  
  39. if (top == 0) {
  40. printf("FRULA");
  41. }
  42. else {
  43. for (a = 0; a < top;a++) {
  44. printf("%c", stack[a]);
  45. }
  46. }
  47. printf("\n");
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0s 11376KB
stdin
aaaabb
aab
stdout
aab