Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- using namespace System;
- using namespace System::Windows::Forms;
- #include <string>
- String^ task(String^ str) {
- int maxpos = 0, maxcount = 0;
- Char maxSymbol;
- for (int i = 0; i < str->Length; i++) {
- Char Symbol = str[i];
- int count = 0;
- int startIndex = i;
- int j = i;
- while (j < str->Length && str[j] == Symbol) {
- count++;
- j++;
- }
- if (count > maxcount) {
- maxSymbol = Symbol;
- maxcount = count;
- maxpos = startIndex;
- }
- }
- str = str->Remove(maxpos, maxcount);
- String^ maxstr = maxcount.ToString() + maxSymbol.ToString();
- str = str->Insert(maxpos, maxstr);
- return str;
- }
Add Comment
Please, Sign In to add comment