Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- vector<string> check_substr(vector<string>& words, string substr){
- vector<string> matched;
- for(string & word : words){
- if(word.size() >= substr.size()) {
- bool unmatched = false;
- for (int j = 0; j < substr.size(); ++j) {
- if(substr[j] != word[j]) {
- unmatched = true;
- break;
- }
- }
- if(!unmatched)
- matched.push_back(word);
- }
- }
- return matched;
- }
- vector<string> separate_words(const string & text, const string & delimeters){
- vector<string> words;
- string temp_s = "";
- for(char i : text){
- if(find(delimeters.begin(), delimeters.end(), i) == delimeters.end()){
- temp_s += i;
- }
- else{
- words.push_back(temp_s);
- temp_s = "";
- }
- }
- words.push_back(temp_s);
- return words;
- }
- int main() {
- string substr = "", s = "";
- cin >> substr >> s;
- vector<string> words = separate_words(s, " ,.;!?:/");
- vector<string> matched = check_substr(words, substr);
- for(string i : matched){
- cout << i << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement