Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace FoldAndSum
- {
- class Program
- {
- public static void Main(string[] args)
- {
- int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int proportion = numbers.Length / 4;
- int[] leftProportion = numbers.Take(proportion).Reverse().ToArray();
- int[] rightProportion = numbers.Skip(proportion * 3).Take(proportion).Reverse().ToArray();
- int[] firstRow = leftProportion.Concat(rightProportion).ToArray();
- int[] secondRow = numbers.Skip(proportion).Take(proportion * 2).ToArray();
- int[] result = firstRow.Select((number, index) => (number + secondRow[index])).ToArray();
- Console.WriteLine(string.Join(" ", result));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment