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