fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. using System.Collections.Generic;
  5.  
  6. namespace Yoba{
  7.  
  8. public class Test
  9. {
  10. public static void Main()
  11. {
  12. var source = new int[] {1, 2, 3, 4, 5, 6, 7};
  13.  
  14. Action<int[]> output = (t) => Console.WriteLine(t.Aggregate(string.Empty, (s, s1)=>string.Format("{0}, {1}", s, s1)).Trim(new char[]{',',' '}));
  15.  
  16. output(source);
  17. source = Enumerable.Range(0, source.Length).Select(x => source[Math.Min(x + 1 - x % 2 * 2, source.Length - 1)]).ToArray();
  18. output(source);
  19.  
  20. }
  21. }
  22. }
Success #stdin #stdout 0.03s 16056KB
stdin
Standard input is empty
stdout
1, 2, 3, 4, 5, 6, 7
2, 1, 4, 3, 6, 5, 7