123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <stdio.h>
- #include <string.h>
- int main() {
- char str[100], sub[100];
- fgets(str, 100, stdin);
- fgets(sub, 100, stdin);
- // Remove newline characters
- str[strcspn(str, "\n")] = '\0';
- sub[strcspn(sub, "\n")] = '\0';
- int str_len = strlen(str);
- int sub_len = strlen(sub);
- char result[100];
- int result_index = 0;
- int i,j;
- for (i = 0; i < str_len; i++) {
- int match = 1;
- for (j = 0; j < sub_len; j++) {
- if (str[i + j] != sub[j]) {
- match = 0;
- break;
- }
- }
- if (match) {
- i += sub_len - 1;
- } else {
- result[result_index++] = str[i];
- }
- }
- result[result_index] = '\0';
- printf("%s\n", result);
- return 0;
- }
|