Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace removeNegativeAndReverse
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. var list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  12. var resultlist = new List<int>();
  13.  
  14.  
  15. for (int i = list.Count - 1; i >= 0; i--)
  16. {
  17. if (list[i] >= 0)
  18. {
  19. resultlist.Add(list[i]);
  20. }
  21.  
  22. }
  23. if (resultlist.Count == 0)
  24. {
  25. Console.WriteLine("empty");
  26. }
  27. else
  28. {
  29. Console.WriteLine(string.Join(" ",resultlist));
  30. }
  31.  
  32.  
  33.  
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement