#include #include using namespace std; void xoaKyTu(char str[255], int k) { for (int i = k; i < strlen(str); i++) str[i] = str[i+1]; } void chenKyTu(char str[255], char x, int k) { int n = strlen(str); for (int i = n; i > k ; i--) str[i] = str[i-1]; str[k] = x; str[n+1] = '\0'; } int demChuoi(char inputStr[100], char findStr[100]) { int n = 0; bool find_ok = false; for (int i = 0; i < strlen(inputStr); i++) { for (int j = 0; j < strlen(findStr); j++) { if (inputStr[i+j] != findStr[j]) { find_ok = false; break; } find_ok = true; } if (find_ok) { n++; } } return n; } void thayTheChuoi(char inputStr[100], char findStr[100], char replaceStr[100]) { bool find_ok = false; for (int i = 0; i < strlen(inputStr); i++) { for (int j = 0; j < strlen(findStr); j++) { if (inputStr[i+j] != findStr[j]) { find_ok = false; break; } find_ok = true; } if (find_ok) { for (int k = 0; k < strlen(findStr); k++) { xoaKyTu(inputStr, i); } for (int k = 0; k < strlen(replaceStr); k++) { chenKyTu(inputStr, replaceStr[k], i + k); } } } } int main() { char str1[100], str2[100], str3[100]; cout<<"Nhap str1: "; fflush(stdin); gets(str1); cout<<"Nhap str2: "; fflush(stdin); gets(str2); cout<<"Nhap str3: "; fflush(stdin); gets(str3); cout<<"So lan xuat hien: "<