Advertisement
FLISEN

Untitled

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