Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _07._Max_Sequence_of_Increasing_Elements
- {
- class MaxSeqIncreasingElements
- {
- static void Main(string[] args)
- {
- int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int counter = 1;
- int counterMax = 0;
- int position = 0;
- for (int i = 0; i < array.Length - 1; i++)
- {
- if (array[i] < array[i + 1])
- {
- counter++;
- if (counter > counterMax)
- {
- counterMax = counter;
- position = i + 1; ;
- }
- }
- else
- {
- counter = 1;
- }
- if (i + 1 == array.Length - 1)
- {
- if (counter > counterMax)
- {
- counterMax = counter;
- position = array[i];
- }
- counter = 1;
- }
- }
- int[] result = new int[counterMax];
- for (int i = 0; i < result.Length; i++)
- {
- result[i] = array[position - counterMax + 1 + i];
- //position++;
- }
- Console.WriteLine(string.Join(" ",result));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment