desislava777

Flip List Sides

Jun 20th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication12
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var number = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToList();
  14. var num = new List<int>();
  15. var nums = new List<int>();
  16. for (int i=1; i<=number.Count-2; i++)
  17. {
  18. nums.Add(number[i]);
  19. }
  20. nums.Reverse();
  21. num.Add(number[0]);
  22. num.AddRange(nums);
  23. num.Add(number[number.Count - 1]);
  24. Console.WriteLine(string.Join(" ", num));
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment