#include<stdio.h> #include<string.h> #include<stdlib.h> void swap(char* a, char* b) { int i, j, n = strlen(a), m = strlen(b); for (i = 0; i < n; i++)a[i] = '\0'; strcat(a, b); } int main() { char s[30][30]; int i, j, k, n; char target_s[105], bth[20], th[20]; gets(target_s); gets(bth); gets(th); n = strlen(target_s); for (i = 0; i < 30; i++) { for (j = 0; j < 30; j++) { s[i][j] = '\0'; } } j = 0; k = 0; for (i = 0; i < n; i++) { if (target_s[i] == ' ') { j++; k = 0; continue; } s[j][k] = target_s[i]; k++; } for (i = 0; i < j + 1; i++) { if (strcmp(s[i], bth) == 0)swap(s[i], th); } for (i = 0; i < j + 1; i++)printf("%s ", s[i]); }