Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication6
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(' ');
- List<int> output = new List<int>();
- List<int> arrayOutput = new List<int>();
- int[] array = new int[input.Length];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = int.Parse(input[i]);
- }
- int previousCounter = 0;
- int counter = 0;
- for (int i = 0; i < array.Length - 1; i++)
- {
- if (array[i] < array[i + 1])
- {
- output.Add(array[i]);
- counter++;
- }
- else
- {
- output.Add(array[i]);
- counter++;
- if (counter > previousCounter)
- {
- arrayOutput.Clear();
- foreach (var item in output)
- {
- arrayOutput.Add(item);
- }
- previousCounter = counter;
- }
- foreach (var item in output)
- {
- Console.Write(item + " ");
- }
- Console.WriteLine();
- output.Clear();
- counter = 0;
- }
- if (i == array.Length - 2)
- {
- if (array[i] < array[i + 1])
- {
- output.Add(array[i + 1]);
- counter++;
- if (counter > previousCounter)
- {
- arrayOutput.Clear();
- foreach (var item in output)
- {
- arrayOutput.Add(item);
- }
- previousCounter = counter;
- }
- foreach (var item in output)
- {
- Console.Write(item + " ");
- }
- Console.WriteLine();
- }
- else
- {
- foreach (var item in output)
- {
- Console.Write(item + " ");
- }
- Console.WriteLine(array[i + 1]);
- }
- }
- }
- Console.WriteLine("Longest:{0}", string.Join(" ", arrayOutput));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment