Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool checkWord(string str)
- {
- bool check = str.length() <= 20;
- for (int i = 0; i < str.length() && check; i++)
- if (!isalpha(str[i])) check = false;
- return check;
- }
- bool notHere(string temp, vector<string> words)
- {
- bool check = true;
- for (int i = 0; i < words.size() && check; i++)
- if (temp == words[i]) check = false;
- return check;
- }
- int main()
- {
- string temp;
- vector<string> words;
- ifstream file("words.txt");
- while (!file.eof())
- {
- file >> temp;
- if (checkWord(temp) && notHere(temp, words))
- words.push_back(temp);
- temp = "";
- }
- for (int i = 0; i < words.size(); i++)
- cout << words[i] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement