Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Main()
- int max = 0;
- int count = 1;
- int startIndex = 0;
- int start=0;
- int endIndex=0;
- for (int i = 0; i < arr.Length - 2; i++)
- {
- startIndex = i;
- while (i<arr.Length-1 && Math.Abs(arr[i] - arr[i + 1]) == 1)
- {
- i++;
- count++;
- }
- if (max < count)
- {
- max=count;
- start=startIndex;
- endIndex=i;
- count=1;
- }
- }
- for (int k = start; k <= endIndex; k++)
- {
- Console.WriteLine(arr[k]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement