Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Longest_block_In_string
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- int endIndex = 0;
- int index = 0;
- int count = 1;
- int maxCount = 0;
- int currIndex = 0;
- while (index != text.Length - 1)
- {
- if (text[index] == text[index + 1])
- {
- currIndex = index + 1;
- count++;
- }
- else
- {
- count = 1;
- }
- if (count > maxCount)
- {
- maxCount = count;
- endIndex = currIndex;
- }
- index++;
- }
- int startIndex = endIndex - maxCount + 1;
- Console.WriteLine(text.Substring(startIndex, maxCount));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement