Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void process(string line, string word) {
- string temp;
- char tmp, tmp2;
- int i, k;
- bool has = false;
- for (i = 0; i < line.length(); i++) {
- tmp = line[i];
- temp += tmp;
- if(tolower(tmp) == tolower(word[0]))
- {
- for(k = i; k < i + word.size(); k++)
- {
- tmp2 = tolower(line[k]);
- if(tmp2 == tolower(word[k - i]))
- {
- has = true;
- }
- else
- {
- has = false;
- break;
- }
- }
- }
- if(tmp == '.' || tmp == '!' || tmp == '?')
- {
- if(has)
- {
- cout << temp << endl;
- has = false;
- }
- temp = "";
- }
- }
- cout << endl;
- }
- int main() {
- string line = "The sea was really rough and the waves were huge. -It was so exciting! -Canoe was full of water but we weren't scary.", word;
- getline(cin, line);
- cin >> word;
- process(line, word);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement