borko9696

Problem 5. Longest Increasing Sequence

Sep 18th, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class LongestIncresingSequence
  9. {
  10.     static void Main()
  11.     {
  12.         int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  13.        
  14.         for (int i = 0; i < arr.Length; i++)
  15.         {
  16.             if (i == arr.Length - 1)
  17.             {
  18.                 if (arr[i - 1] < arr[i])
  19.                 {
  20.                     Console.Write("{0} ", arr[i]);
  21.                 }
  22.                 else
  23.                 {
  24.                     Console.WriteLine("{0}", arr[i]);
  25.                 }
  26.             }
  27.             else if (arr[i] < arr[i + 1])
  28.             {
  29.                 Console.Write("{0} ", arr[i]);
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine("{0}", arr[i]);
  34.             }
  35.         }
  36.         Console.WriteLine();
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment