Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- internal class LongestSequence
- {
- private static void Main()
- {
- Console.Write("Entere Numbers: ");
- string input = Console.ReadLine();
- int[] numbers = input.Split(' ').Select(int.Parse).ToArray();
- List<int> biggest = new List<int>();
- List<int> current = new List<int>();
- current.Add(numbers[0]);
- for (int i = 1; i < numbers.Length; i++)
- {
- bool isBigger = CompareValues(numbers[i-1], numbers[i]);
- if (isBigger)
- {
- current.Add(numbers[i]);
- }
- if (current.Count > biggest.Count)
- {
- biggest = current.ToList();
- }
- if(!isBigger)
- {
- PrintingValues(current);
- current.Clear();
- current.Add(numbers[i]);
- }
- }
- PrintingValues(current);
- Console.Write("Longest: ");
- PrintingValues(biggest);
- }
- static void PrintingValues(List<int> thisList)
- {
- thisList.ForEach(x => Console.Write(x + " "));
- Console.WriteLine();
- }
- static bool CompareValues(int a, int b)
- {
- bool check = false;
- if (a < b)
- {
- check = true;
- }
- return check;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement