Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string maxLetters = "";
- int maxIndex = 0, seq = 0;
- char ch, last;
- int[] letters = new int[26];
- ch = char.Parse(Console.ReadLine());
- last = ch;
- while (ch != '*')
- {
- if (ch == last)
- seq++;
- else
- {
- letters[last - 'a'] = Math.Max(letters[last - 'a'], seq);
- seq = 1;
- }
- last = ch;
- ch = char.Parse(Console.ReadLine());
- }
- letters[last - 'a'] = Math.Max(letters[last - 'a'], seq);
- for (int i = 0; i < letters.Length; i++)
- {
- if (letters[i] > 0)
- {
- Console.Write("({0},{1}) , ", (char)(i + 'a'), letters[i]);
- if (letters[i] > letters[maxIndex])
- {
- maxIndex = i;
- maxLetters = ((char)(i + 'a')).ToString();
- }
- else if (letters[i] == letters[maxIndex])
- maxLetters += " , " + (char)(i + 'a');
- }
- }
- Console.WriteLine("/n" +maxLetters);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement