Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace ListsHomeworkk
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<int> numbers = Console.ReadLine()
  12. .Split()
  13. .Select(int.Parse)
  14. .ToList();
  15.  
  16. List<int> counters = new List<int>();
  17. var counter = 0;
  18. var best = 0;
  19.  
  20. for (int i = 0; i < numbers.Count - 1; i++)
  21. {
  22. var current = numbers[i];
  23.  
  24.  
  25. if (numbers[i] == numbers[i + 1])
  26. {
  27. counter++;
  28. if (counter > best)
  29. {
  30. counters.RemoveRange(0, counters.Count);
  31.  
  32. best = counter;
  33. for (int j = 0; j <= best; j++)
  34. {
  35. counters.Insert(j, current);
  36. }
  37.  
  38. }
  39. }
  40. else
  41. {
  42. counter = 0;
  43. }
  44.  
  45.  
  46.  
  47. }
  48.  
  49. Console.WriteLine(string.Join(" ", counters));
  50.  
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement