Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define db(x) cerr << #x << ': ' << x << endl;
- using namespace std;
- int main(){
- string word, newer, ans;
- while (getline(cin, word)){
- stringstream final;
- getline(cin, newer);
- getline(cin, ans);
- bool ok = false, tag = false;
- for (int i = 0; i < ans.length(); i++){
- if (ans[i] == '<'){
- tag = true;
- }else{
- if (ans[i] == '>')
- tag = false;
- }
- if (tolower(ans[i]) == tolower(word[0]) && tag){
- ok = true;
- for (int j = i+1, h = 1; h < word.length(); j++, h++){
- if (tolower(ans[j]) != tolower(word[h])){
- ok = false;
- break;
- }
- }
- if (ok){
- final << newer;
- i += (word.length() - 1);
- }else{
- final << ans[i];
- }
- }else{
- final << ans[i];
- }
- }
- cout << final.str() << endl; // remplaza todas las ocurrencias
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement