Guest User

Untitled

a guest
Jul 29th, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 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.  
  8. class MaxSequence
  9. {
  10. static void Main(string[] args)
  11. {
  12. List<int> numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  13. int maxnumbers = 0;
  14. int count = 1;
  15. int maxcount = 1;
  16. int pos = 0;
  17. while (pos < numbers.Count - 1)
  18. {
  19.  
  20. if (numbers[pos] == numbers[pos + 1])
  21. {
  22. count++;
  23.  
  24. if (count > maxcount)
  25. {
  26. maxcount = count;
  27. maxnumbers = numbers[pos];
  28. }
  29.  
  30. }
  31. else
  32. {
  33. count = 1;
  34. }
  35. pos++;
  36. if (maxcount == 1)
  37. {
  38. maxnumbers = numbers[0];
  39. }
  40. }
  41. for (int i = 0; i < maxcount; i++)
  42. {
  43. Console.Write(maxnumbers);
  44. Console.Write(" ");
  45.  
  46. }
  47. }
  48. }
Add Comment
Please, Sign In to add comment