Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace removeNegativeAndReverse
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- var list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- var resultlist = new List<int>();
- for (int i = list.Count - 1; i >= 0; i--)
- {
- if (list[i] >= 0)
- {
- resultlist.Add(list[i]);
- }
- }
- if (resultlist.Count == 0)
- {
- Console.WriteLine("empty");
- }
- else
- {
- Console.WriteLine(string.Join(" ",resultlist));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement