Advertisement
zhpapazov

Untitled

Oct 18th, 2016
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace RemoveNegativesAndReverse
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. var numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  12. var results = new List<int>();
  13.  
  14. for (int i = numbers.Count - 1; i >= 0; i--)
  15. {
  16. if (numbers[i] > 0)
  17. {
  18. results.Add(numbers[i]);
  19. }
  20. else
  21. {
  22. results.Remove(numbers[i]);
  23. }
  24. }
  25.  
  26. foreach (var items in results)
  27. {
  28. Console.Write("{0} ", items);
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement