Advertisement
APXOHT

Untitled

Jan 6th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2.  
  3. class MaximumIncreasingSequence
  4. {
  5.     static void Main()
  6.     {
  7.         int[] array = { 2, 1, 1, 2, 6, 4, 5, 5, 5, 5, 5, 2, 2, 1 };
  8.         int maxSequence = 0;
  9.         int sequence = 1;
  10.         string sequenceNumbers = "";
  11.         string maxSequenceNumbers = "";
  12.         for (int i = 0; i < array.Length - 1; i++)
  13.         {
  14.             if (array[i] < array[i + 1])
  15.             {
  16.                 sequence++;
  17.                 sequenceNumbers += array[i] + " ";
  18.             }
  19.             else
  20.             {
  21.                 if (maxSequence < sequence)
  22.                 {
  23.                     maxSequence = sequence;
  24.                     sequenceNumbers += array[i] + " ";
  25.                     maxSequenceNumbers = sequenceNumbers;
  26.                 }
  27.                 sequence = 1;
  28.                 sequenceNumbers = "";
  29.             }
  30.         }
  31.         Console.WriteLine(maxSequenceNumbers);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement