Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Problem_9._Print_Maximum_Increasing_Subsequence
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(' ');
- int startIndex = -1;
- int endIndex = -1;
- int counter = 1;
- int position = 1;
- int maxCounter = 0;
- for (int i = 0; i < input.Length; i++)
- {
- int currNum = int.Parse(input[i]);
- if (currNum < int.Parse(input[position]))
- {
- counter++;
- if (counter >= maxCounter)
- {
- maxCounter = counter;
- endIndex = position;
- }
- }
- else
- {
- counter = 1;
- }
- position++;
- if (position == input.Length)
- {
- break;
- }
- }
- startIndex = endIndex - maxCounter + 1;
- for (int i = startIndex; i <= endIndex; i++)
- {
- Console.Write(input[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment