Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 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 _04
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. { //4. Write a program that finds the maximal sequence of equal elements in an array.
  13.  
  14. int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  15.  
  16. int count = 0;
  17. int maxSequence = 0;
  18. int value = 0;
  19.  
  20. for (int i = 0; i < nums.Length; i++)
  21. {
  22. if (nums[i] == nums[i + 1])
  23. {
  24. count++;
  25. if (maxSequence < count)
  26. {
  27. maxSequence = count;
  28. }
  29. value = nums[i];
  30. }
  31. else
  32. {
  33. count = 0;
  34. }
  35.  
  36.  
  37. }
  38. if (maxSequence == 0)
  39. {
  40. Console.WriteLine("there are not sequane");
  41. }
  42. else
  43. {
  44. Console.WriteLine("yes,there are seq {0}", value);
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement