Advertisement
tomasaccini

Untitled

Jul 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdbool.h>
  4.  
  5. void imprimir(const char* A, const char* B) {
  6.     size_t len_A = strlen(A);
  7.     size_t len_B = strlen(B);
  8.  
  9.     for (size_t i = 0; i < len_A; ++i) {
  10.         if (i + len_B > len_A) {
  11.             printf("%c", A[i]);
  12.             continue;
  13.         }
  14.         bool coincide = true;
  15.         for (size_t j = 0; j < len_B; ++j) {
  16.             if (A[i + j] != B[j]) {
  17.                 coincide = false;
  18.                 break;
  19.             }
  20.         }
  21.         if (!coincide) {
  22.             printf("%c", A[i]);
  23.         } else {
  24.             i += len_B - 1;
  25.         }
  26.     }
  27. }
  28.  
  29.  
  30. int main() {
  31.     imprimir("Make America great again", "great ");
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement