Advertisement
SkeptaProgrammer

Untitled

Jun 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. bool checkWord(string str)
  2. {
  3.     bool check = str.length() <= 20;
  4.     for (int i = 0; i < str.length() && check; i++)
  5.         if (!isalpha(str[i])) check = false;
  6.     return check;
  7. }
  8.  
  9. bool notHere(string temp, vector<string> words)
  10. {
  11.     bool check = true;
  12.     for (int i = 0; i < words.size() && check; i++)
  13.         if (temp == words[i]) check = false;
  14.     return check;
  15. }
  16.  
  17. int main()
  18. {  
  19.     string temp;
  20.     vector<string> words;
  21.    ifstream file("words.txt");
  22.    while (!file.eof())
  23.    {
  24.        file >> temp;
  25.        if (checkWord(temp) && notHere(temp, words))
  26.            words.push_back(temp);
  27.        temp = "";
  28.    }
  29.    for (int i = 0; i < words.size(); i++)
  30.        cout << words[i] << endl;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement