Advertisement
Guest User

Untitled

a guest
Aug 17th, 2016
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace Arrays
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] nums = Console.ReadLine().Split().Select(int.Parse).ToArray();
  11.             List<int> resultList = new List<int>();
  12.             List<int> tempList = new List<int>();
  13.  
  14.             for(int index = 0; index  < nums.Length - 1 ; index++ )
  15.             {
  16.                 var currentNum = nums[index];
  17.                 var nextNum = nums[index + 1];
  18.                 tempList.Add(currentNum);
  19.                 while(currentNum < nextNum)
  20.                 {
  21.                     tempList.Add(nextNum);
  22.                     currentNum = nextNum;
  23.                     index++;
  24.                     if(index == nums.Length - 1)
  25.                     {
  26.                         continue;
  27.                     }
  28.                     nextNum = nums[index + 1];
  29.                 }
  30.                 if(tempList.Count > resultList.Count)
  31.                 {
  32.                     resultList.Clear();
  33.                     resultList.AddRange(tempList);
  34.                 }
  35.  
  36.                 tempList.Clear();
  37.             }
  38.             Console.WriteLine(string.Join(" ",resultList));
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement