5.Top Integers
Здравейте, някой би ли ми помогнал дава ми 80/100 в джъджа.
Write a program to find all the top integers in an array. A top integer is an integer which is bigger than all the elements to its right.
Examples
Input |
Output |
1 4 3 2 |
4 3 2 |
14 24 3 19 15 17 |
24 19 17 |
27 19 42 2 13 45 48 |
48 |
using System;
using System.ComponentModel;
using System.Linq;
namespace ToIntegers
{
class Program
{
static void Main()
{
long[] inputArr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
//int[] novArr = new int[];
for (long i = 0; i <= inputArr.Length; i++)
{
//int[] novArr = new int[i+1];
for (long j = i; j < inputArr.Length; j++)
{
if (inputArr[i] < inputArr[j])
{
break;
}
else if (inputArr[i] >= inputArr[j] && inputArr.Length - 1 == j)
{
Console.Write(inputArr[i] + " ");
}
}
}
Console.WriteLine();
}
}
}