Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class IncreasingSequence
- {
- static void Main()
- {
- int[] array = { 3, 2, 3, 4, 2, 4, 5, 6, 7 };
- int length = 0;
- int maxLength = 0;
- string sequence = null;
- string maxSequence = null;
- for (int i = 0; i < array.Length-1; i++)
- {
- if (array[i] < array[i + 1]&&i+1 != array.Length-1)
- {
- length++;
- sequence += array[i];
- }
- else if (length >= maxLength)
- {
- sequence +=array[i];
- if (array[i] < array[i + 1] && i + 1 == array.Length - 1)
- {
- length++;
- sequence += array[i + 1];
- }
- maxLength = length;
- maxSequence = sequence;
- sequence = null;
- length = 0;
- }
- }
- Console.WriteLine(maxSequence);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement