-
-
Save SonnyRR/5c37e9c50f61a07cd2736ce8d5921edb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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