Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _8._LongestBlockInString
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- int counter = 0;
- int maxCounter = 0;
- string result = string.Empty;
- for (int i = 1; i <= input.Length -1; i++)
- {
- if (result.Length >= input.Length - i)
- {
- break;
- }
- if (input[i-1] == input[i] )
- {
- counter++;
- if (counter >= maxCounter)
- {
- maxCounter = counter;
- result = new string(input[i], maxCounter + 1);
- }
- }
- else
- {
- counter = 0;
- }
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement