Advertisement
nassss

Untitled

Jan 9th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _8._LongestBlockInString
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string input = Console.ReadLine();
  10. int counter = 0;
  11. int maxCounter = 0;
  12. string result = string.Empty;
  13.  
  14. for (int i = 1; i <= input.Length -1; i++)
  15. {
  16. if (result.Length >= input.Length - i)
  17. {
  18. break;
  19. }
  20. if (input[i-1] == input[i] )
  21. {
  22. counter++;
  23.  
  24. if (counter >= maxCounter)
  25. {
  26. maxCounter = counter;
  27. result = new string(input[i], maxCounter + 1);
  28. }
  29. }
  30. else
  31. {
  32. counter = 0;
  33. }
  34. }
  35. Console.WriteLine(result);
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement