#include <iostream> #include <string> using namespace std; int main(void) { string org, match; while (getline(cin, org)){ getline(cin, match); string res; for (int i = 0; i < org.size(); ++i) { if(org[i]!=match[0]){ res += org[i]; }else{ int index_org=i+1; int index_match = 1; bool flag = true; while(true){ if(org[index_org]==' '){ index_org +=1; }else{ if(org[index_org]!=match[index_match]){ flag = false; }else{ index_org += 1; index_match += 1; } } if(index_match>=match.size()){ break; } if(flag==false){ break; } } if(flag){ if(i>=1&&org[i-1]!=' ') { res += ' '; } res += match; res += ' '; i = index_org-1; }else{ res += org[i]; } } } cout << res << endl; } return 0; }
全部评论
(0) 回帖