Advertisement
alexbancheva

TopIntegers_Arrays_Exercises

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