-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpa_lab_4_5_7_(3)-B.cpp
57 lines (46 loc) · 1.04 KB
/
cpa_lab_4_5_7_(3)-B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <vector>
using namespace std;
bool iequals(const string& a, const string& b)
{
unsigned int sz = a.size();
if (b.size() != sz)
return false;
for (unsigned int i = 0; i < sz; ++i)
if (tolower(a[i]) != tolower(b[i]))
return false;
return true;
}
vector<string> split(string s, char c)
{
vector<string> res = vector<string>();
string temp;
do
{
temp = s.substr(0, s.find_first_of(c));
res.push_back(temp);
s = s.substr(s.find_first_of(c) + 1);
}while (s.find_first_of(c) != string::npos);
res.push_back(s);
return res;
}
int main()
{
string stop_words, sentence;
getline(cin, stop_words);
vector<string> words = split(stop_words, ',');
getline(cin, sentence);
bool print = false;
vector<string> sent = split(sentence, ' ');
for (int i = 0; i < sent.size(); i++)
{
print = true;
for (int j = 0; j < words.size(); j++)
if (iequals(words[j], sent[i]))
print = false;
if (print)
cout << sent[i] << " ";
}
cout << endl;
return 0;
}