Advertisement
Spocoman

05. Remove Negatives and Reverse

Feb 1st, 2022 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace RemoveNegativesAndReverse
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> numbers = Console.ReadLine()
  12.                 .Split(" ")
  13.                 .Select(int.Parse)
  14.                 .ToList();
  15.  
  16.             numbers.Reverse();
  17.             numbers.RemoveAll(n => n < 0);
  18.  
  19.             Console.WriteLine(numbers.Count == 0 ? "empty" : string.Join(" ", numbers));
  20.         }
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement