Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Write a program that finds the maximal increasing sequence
- //in an array. Example: {3, 2, 3, 4, 2, 2, 4} {2, 3, 4}.
- using System;
- class MaximalIncreasingSequencesInArray
- {
- static void Main()
- {
- int[] array = new int[10];
- int counter = 1;
- int count = 0;
- int firstNumber = 0;
- for (int index = 0; index < 10; index++)
- {
- array[index] = int.Parse(Console.ReadLine());
- }
- for (int index = 0; index < 9; index++)
- {
- if (array[index] + 1 == array[index + 1])
- {
- counter++;
- }
- else
- {
- counter = 1;
- }
- if (count < counter)
- {
- count = counter;
- firstNumber = array[index] + 1;
- }
- }
- for (int i = count - 1; i >= 0; i--)
- {
- Console.Write((firstNumber - i) + ", ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement