simonradev

Малко Схеми

Nov 13th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace FoldAndSum
  6. {
  7.     class Program
  8.     {
  9.         public static void Main(string[] args)
  10.         {
  11.             int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  12.            
  13.             int proportion = numbers.Length / 4;
  14.            
  15.             int[] leftProportion = numbers.Take(proportion).Reverse().ToArray();
  16.             int[] rightProportion = numbers.Skip(proportion * 3).Take(proportion).Reverse().ToArray();
  17.             int[] firstRow = leftProportion.Concat(rightProportion).ToArray();
  18.             int[] secondRow = numbers.Skip(proportion).Take(proportion * 2).ToArray();
  19.             int[] result = firstRow.Select((number, index) => (number + secondRow[index])).ToArray();
  20.            
  21.             Console.WriteLine(string.Join(" ", result));
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment