Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <vector>
- #include <stdio.h>
- #include <cmath>
- #include <math.h>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <deque>
- #include <ctime>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef unsigned int ui;
- int main()
- {
- string s;
- getline(cin, s);
- string y;
- string u = s;
- queue<pair<int, int>>next;
- ll last;
- cin >> y;
- ll i = -1;
- i = s.find(y);
- if (i == 4294967295)
- return cout << "I HAVE FAILED!!!", 0;
- next.push({ i, i + y.size()-1});
- last = i + y.size() - 1;
- while (cin >> y)
- {
- i = s.substr(last+2,s.size()-last-2).find(y);
- if (i == 4294967295)
- return cout << "I HAVE FAILED!!!", 0;
- else
- i += last + 2;
- next.push({ i, i+y.size()-1 });
- last = i + y.size() - 1;
- }
- for (int i = 0; i < s.size(); i++)
- {
- if (!next.empty())
- if (i >= next.front().first&&i <= next.front().second)
- {
- cout << s[i];
- if (i + 1 > next.front().second)
- next.pop();
- }
- else
- {
- if (s[i] != ' ')
- cout << "_";
- else
- cout << s[i];
- }
- else
- {
- if (s[i] != ' ')
- cout << "_";
- else
- cout << s[i];
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement