Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String^ task(String^ str, int& count) {
- String^ tempstr = str;
- int maxpos = 0, maxcount = 0;
- Char maxsymbol;
- for (int i = 0; i < str->Length; i++) {
- Char Symbol = str[i];
- int count = 1;
- if (Symbol != ' ' && tempstr->IndexOf(Symbol, i) > -1) { // Если символ не равен пробелу, и такие символы в строке еще есть
- for (int j = i + 1; j < tempstr->Length; j++) {
- if (tempstr[j] == Symbol) {
- count++;
- tempstr = tempstr->Remove(j, 1);
- }
- else {
- break;
- }
- }
- if (count > maxcount) {
- maxsymbol = Symbol;
- maxcount = count;
- maxpos = i;
- }
- }
- }
- str = str->Remove(maxpos, maxcount+1);
- MessageBox::Show(str, "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error);
- String^ maxstr = maxcount.ToString() + maxsymbol.ToString();
- str = str->Insert(maxpos, maxstr);
- return str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement