Skip to content

Instantly share code, notes, and snippets.

@SonnyRR
Created February 6, 2019 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SonnyRR/5c37e9c50f61a07cd2736ce8d5921edb to your computer and use it in GitHub Desktop.
Save SonnyRR/5c37e9c50f61a07cd2736ce8d5921edb to your computer and use it in GitHub Desktop.
namespace MySandBox
{
using System;
using System.Collections.Generic;
using System.Linq;
public class StartUp
{
public static void Main()
{
int[] numbers = Console.ReadLine()
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => int.Parse(x))
.ToArray();
var outputCollection = FindBiggerElements(numbers);
string output = string.Join(' ', outputCollection);
Console.WriteLine(output);
}
public static List<int> FindBiggerElements(int[] numbers)
{
List<int> biggerElements = new List<int>();
for (int i = 0; i < numbers.Length - 1; i++)
{
if (numbers[i] > numbers[i + 1])
{
biggerElements.Add(numbers[i]);
}
}
biggerElements.Add(numbers[numbers.Length - 1]);
return biggerElements;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment