Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- struct keyWord
- {
- string Engine;
- void setName(string eng)
- {
- Engine = eng;
- }
- bool isThisWord(string word)
- {
- if(word == Engine) return true;
- return false;
- }
- };
- int main()
- {
- ifstream file2("file2.txt");
- const int Qant = 4;
- keyWord N[Qant]; // array of key words;
- int S[Qant]; // quantity of fucking words in this fucking text
- for(int i = 1; i < Qant; i++) S[i] = 0;
- N[1].setName("this");
- N[2].setName("for");
- N[3].setName("mutable");
- string buffer;
- for(int i=1; !file2.eof(); i++)
- {
- file2 >> buffer;
- for(int j = 1; j < Qant; j++)
- {
- if(N[j].isThisWord(buffer))S[j]++;
- }
- }
- for (int i = 1; i < Qant; i++)
- {
- cout << "word \"" << N[i].Engine << "\" contains fucking " << S[i] << " times \n";
- }
- file2.close();
- return 0;
- }
Add Comment
Please, Sign In to add comment