Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //exercise 14
- #include <string> //delete words which include all letters from the first word
- #include <fstream>
- #include <vector>
- using namespace std;
- bool includes(string first, string s)
- {
- vector<char> a;
- for(unsigned i = 0; i < first.length(); i++)
- if (first[i] >= 'a' && first[i] <= 'z' || first[i] >= 'A' && first[i] <= 'Z' )
- a.push_back(first[i]);
- //for(unsigned j = 0; j < a.size(); j++)
- // cout << a[j] << " ";
- //cout << endl;
- vector<bool> incAll(a.size(), true);
- for(unsigned i = 0; i < s.length(); i++)
- for(unsigned j = 0; j < a.size(); j++)
- {
- if (a[j] == s[i])
- incAll[j] = false;
- }
- bool NOinclusion = false;
- //for(unsigned j = 0; j < incAll.size(); j++)
- // cout << incAll[j] << " ";
- //cout << endl;
- for(unsigned j = 0; j < incAll.size(); j++)
- NOinclusion += incAll[j];
- //cout << NOinclusion << endl;
- if (NOinclusion)
- return false;
- else
- return true;
- }
- int main()
- {
- ifstream in("input.txt");
- ofstream out("output.txt");
- string first;
- string s;
- bool firstWas = false;
- bool firstNoErase = true;
- while(in >> s)
- {
- if (!firstWas)
- {
- firstWas = true;
- first = s;
- }
- if (!includes(first, s) || firstNoErase)
- out << s << " ";
- firstNoErase = false;
- }
- in.close();
- out.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment