Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. void Main()
  2.  
  3. int max = 0;
  4. int count = 1;
  5. int startIndex = 0;
  6. int start=0;
  7. int endIndex=0;
  8. for (int i = 0; i < arr.Length - 2; i++)
  9. {
  10. startIndex = i;
  11. while (i<arr.Length-1 && Math.Abs(arr[i] - arr[i + 1]) == 1)
  12. {
  13. i++;
  14. count++;
  15. }
  16. if (max < count)
  17. {
  18. max=count;
  19. start=startIndex;
  20. endIndex=i;
  21. count=1;
  22.  
  23. }
  24.  
  25.  
  26.  
  27. }
  28. for (int k = start; k <= endIndex; k++)
  29. {
  30. Console.WriteLine(arr[k]);
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement