Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class MaximalIncreasingSequence
- {
- static void Main()
- {
- Console.Write("Type in the size of the Array: ");
- int arraySize = int.Parse(Console.ReadLine());
- int[] arr = new int[arraySize];
- int arrayValue, startNumber = 0,count = 0, bestCount = 0;
- string sequence = " ", bestSequence = " ";
- for (int index = 0; index < arraySize; index++)
- {
- Console.Write("Position [{0}]: ", index);
- arrayValue = int.Parse(Console.ReadLine());
- arr[index] = arrayValue;
- }
- for (int i = 0; i < arr.Length; i++)
- {
- if (startNumber < arr[i])
- {
- count++;
- startNumber = arr[i];
- if (count >= bestCount)
- {
- bestCount = count;
- sequence += arr[i] + " ";
- bestSequence = sequence;
- }
- }
- else if (startNumber >= arr[i])
- {
- startNumber = arr[i];
- sequence = " ";
- sequence += arr[i] + " ";
- count = 1;
- }
- }
- Console.WriteLine(bestSequence);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement