Guest User

Untitled

a guest
May 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. struct keyWord
  7. {
  8.     string Engine;
  9.     void setName(string eng)
  10.     {
  11.         Engine = eng;
  12.     }
  13.  
  14.  
  15.     bool isThisWord(string word)
  16.     {
  17.         if(word == Engine) return true;
  18.         return false;
  19.     }
  20. };
  21.  
  22. int main()
  23. {
  24.     ifstream file2("file2.txt");
  25.     const int Qant = 4;
  26.     keyWord N[Qant]; // array of key words;
  27.    
  28.     int S[Qant]; // quantity of fucking words in this fucking text
  29.     for(int i = 1; i < Qant; i++) S[i] = 0;
  30.     N[1].setName("this");
  31.     N[2].setName("for");
  32.     N[3].setName("mutable");
  33.    
  34. string buffer;
  35.    
  36.     for(int i=1; !file2.eof(); i++)
  37.     {        
  38.         file2 >> buffer;
  39.         for(int j = 1; j < Qant; j++)
  40.         {
  41.             if(N[j].isThisWord(buffer))S[j]++;
  42.         }
  43.        
  44.        
  45.     }
  46.      
  47.     for (int i = 1; i < Qant; i++)
  48.     {
  49.         cout << "word \"" << N[i].Engine << "\" contains fucking " << S[i] << " times \n";
  50.     }
  51.    
  52.    
  53.     file2.close();    
  54.     return 0;
  55. }
Add Comment
Please, Sign In to add comment