StoimenK

C#_Lists_1.5._Remove_Negatives_and_Reverse

Feb 28th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _1._5._Remove_Negatives_and_Reverse
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             List<int> inputNum = Console.ReadLine().Split().Select(int.Parse).ToList();
  14.  
  15.             inputNum.RemoveAll(n => n < 0);
  16.  
  17.             if (inputNum.Count == 0)
  18.             {
  19.                 Console.WriteLine("empty");
  20.             }
  21.             inputNum.Reverse();
  22.  
  23.             Console.WriteLine(string.Join(" ", inputNum));
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment