Krasimir_Slavov

Untitled

Feb 13th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Ex_Arr_Top_Integers
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.             for (int i = 0; i < arr.Length; i++)
  12.             {
  13.                 bool topInteger = true;
  14.                 if (i < arr.Length - 1)
  15.                 {
  16.                     if (arr[i] > arr[i + 1])
  17.                     {
  18.                         for (int j = i + 1; j < arr.Length; j++)
  19.                         {
  20.                             if (arr[i] < arr[j])
  21.                             {
  22.                                 topInteger = false;
  23.                                 break;
  24.                             }
  25.                         }
  26.                         if (topInteger)
  27.                         {
  28.                             Console.Write($"{arr[i]} ");
  29.                         }
  30.                     }
  31.                 }
  32.                 else
  33.                 {
  34.                     Console.WriteLine($"{arr[i]} ");
  35.                 }
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment