Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _07.MaxSequenceOfIncreasingElements
- {
- public class StartUp
- {
- public static void Main()
- {
- long[] numbers = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToArray();
- int start = 0;
- int bestStart = 0;
- int length = 1;
- int bestLength = 1;
- for (int i = 0; i < numbers.Length - 1; i++)
- {
- if (numbers[i] < numbers[i + 1])
- {
- length++;
- if (length > bestLength)
- {
- bestStart = start;
- bestLength = length;
- }
- }
- else
- {
- start = i + 1;
- length = 1;
- }
- }
- for (int i = 0; i < bestLength; i++)
- {
- Console.Write(numbers[bestStart + i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment