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 RemoveNegativesAndReversV3
- {
- class RemoveNegativesaAndReversV3
- {
- static void Main()
- {
- List<int> nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- for (int i = 0; i < nums.Count; i++)
- {
- if(nums[i] < 0)
- {
- nums.RemoveAt(i);
- i--;
- }
- }
- nums.Reverse();
- if(nums.Count > 0)
- {
- Console.WriteLine(string.Join(" ",nums));
- }
- else
- {
- Console.WriteLine("empty");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment