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 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 = 0;
- int* mas = new int[word.length()];
- for (int l = 0; l < word.length(); l++)
- {
- mas[l] = 0;
- }
- for (int t = 0; t < word.length(); t++)
- {
- if (word.find(word[t]) <= t)
- {
- mas[word.find_first_of(word[t])]++;
- }
- }
- for (int l = 0; l < word.length(); l++)
- {
- if (mas[l] > maxs1)
- {
- maxs1 = mas[l];
- }
- }
- if (maxs1 > maxrep)
- {
- maxrep = maxs1;
- }
- delete[] mas;
- }
- return maxrep;
- ss.str("");
- }
- void entering(int maxrep, string text1)
- {
- string rez;
- string word;
- stringstream s(text1);
- while (s >> word)
- {
- int maxs1 = 0;
- int* mas = new int[word.length()];
- for (int l = 0; l < word.length(); l++)
- {
- mas[l] = 0;
- }
- for (int t = 0; t < word.length(); t++)
- {
- if (word.find(word[t]) <= t)
- {
- mas[word.find_first_of(word[t])]++;
- }
- }
- for (int l = 0; l < word.length(); l++)
- {
- if (mas[l] > maxs1)
- {
- maxs1 = mas[l];
- }
- }
- if (maxs1 > maxrep)
- {
- maxrep = maxs1;
- }
- if (maxs1 == maxrep)
- {
- rez += word;
- rez += " ";
- }
- delete[] mas;
- }
- cout << rez;
- s.str("");
- }
Add Comment
Please, Sign In to add comment