Ronka

Untitled

Jun 8th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 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 _8zad
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14.  
  15. int currencount = 1;
  16. int maxcount = 0;
  17. int currentelement = 0;
  18. int maxelement=0;
  19.  
  20. for (int i = 1; i < arr.Length; i++)
  21. {
  22. if (arr[i-1] == arr[i])
  23. {
  24. currencount++;
  25. currentelement = arr[i - 1];
  26.  
  27. if (maxcount < currencount)
  28. {
  29. maxelement = currentelement;
  30. maxcount = currencount;
  31. }
  32.  
  33. }
  34. else
  35. {
  36. currencount = 1;
  37. }
  38.  
  39. if (maxcount < currencount)
  40. {
  41. maxelement = currencount;
  42. maxcount = currentelement;
  43. }
  44.  
  45. }
  46.  
  47.  
  48. for (int i = 0; i < maxcount; i++)
  49. {
  50. Console.Write(maxelement + " ");
  51. }
  52.  
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment