Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- int searching_of_repeats(string);
- void entering(int, string);
- int ff(int, string);
- int main()
- {
- cout << "Enter text: " << endl;
- string text, rez;
- getline(cin, text);
- int maxs = searching_of_repeats(text);
- entering(maxs, text);
- return 0;
- }
- int searching_of_repeats(string str)
- {
- string word;
- int maxrep = 0;
- stringstream ss(str);
- while (ss >> word)
- {
- int maxs1 = ff(maxrep, word);
- if (maxs1 > maxrep)
- {
- maxrep = maxs1;
- }
- }
- return maxrep;
- ss.str("");
- }
- void entering(int maxrep, string text1)
- {
- string rez;
- string word;
- stringstream s(text1);
- while (s >> word)
- {
- int maxs1=ff(maxrep, word);
- if (maxs1 > maxrep)
- {
- maxrep = maxs1;
- }
- if (maxs1 == maxrep)
- {
- rez += word;
- rez += " ";
- }
- }
- cout << rez;
- s.str("");
- }
- int ff(int maxrep1, string word1)
- {
- int maxs1 = 0;
- int* mas = new int[word1.length()];
- for (int l = 0; l < word1.length(); l++)
- {
- mas[l] = 0;
- }
- for (int t = 0; t < word1.length(); t++)
- {
- if (word1.find(word1[t]) <= t)
- {
- mas[word1.find_first_of(word1[t])]++;
- }
- }
- for (int l = 0; l < word1.length(); l++)
- {
- if (mas[l] > maxs1)
- {
- maxs1 = mas[l];
- }
- }
- delete[] mas;
- return maxs1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement