Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _1._5._Remove_Negatives_and_Reverse_V2
- {
- class Program
- {
- static void Main() // Without lambda function // Lambda functionality is exchnaged with for Loop
- {
- List<int> inputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- for (int i = 0; i < inputNum.Count; i++)
- {
- if (inputNum[i] < 0)
- {
- inputNum.RemoveAt(i--);
- }
- }
- if (inputNum.Count == 0)
- {
- Console.WriteLine("empty");
- }
- inputNum.Reverse();
- Console.WriteLine(string.Join(" ", inputNum));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement