Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2016
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Array
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var array1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. int count_max = 0;
  15. int start_max = 0;
  16. int count = 0;
  17. for (int i = 0; i < array1.Length-1; i++)
  18. {
  19. count = 0;
  20. while (array1[i+count]==array1[i+1+count])
  21. {
  22. count++;
  23. if (i + 1 + count > array1.Length - 1)
  24. {
  25. break;
  26. }
  27.  
  28. }
  29. if (count>count_max)
  30. {
  31. count_max = count;
  32. start_max = i;
  33. }
  34.  
  35. }
  36. for (int i = start_max; i <= start_max+ count_max; i++)
  37. {
  38. Console.Write($"{array1[i]} ");
  39. }
  40. Console.WriteLine();
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement