Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ExamPreparation
- {
- class Startup
- {
- static void Main()
- {
- int[] numbers = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- var currStart = 0;
- var currSequence = 0;
- var maxStart = 0;
- var maxSequence = 0;
- for (int i = 1; i < numbers.Length; i++)
- {
- if (numbers[i] - numbers[i - 1] >= 1)
- {
- currSequence++;
- currStart = i - currSequence;
- if (currSequence > maxSequence)
- {
- maxSequence = currSequence;
- maxStart = currStart;
- }
- }
- else
- {
- currSequence = 0;
- }
- }
- for (int i = maxStart; i <= maxStart + maxSequence; i++)
- {
- Console.Write($"{numbers[i]} ");
- }
- Console.WriteLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment