svetlyoek

Untitled

Feb 7th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. namespace ConsoleApp160
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int[] array1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  10. int start = 0;
  11. int count = 0;
  12. int max = 0;
  13. for (int i = 0; i < array1.Length - 1; i++)
  14. {
  15. if (array1[i] == array1[i + 1])
  16. {
  17. count++;
  18. if (count > max)
  19. {
  20. start = i - count;
  21. max = count;
  22. }
  23. }
  24. else
  25. {
  26. count = 0;
  27. }
  28. }
  29. for (int i = start + 1; i <= start + max + 1; i++)
  30. {
  31. Console.Write(array1[i] + " ");
  32. }
  33. Console.WriteLine();
  34.  
  35. }
  36. }
  37.  
  38. }
Add Comment
Please, Sign In to add comment