Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace ExamPreparation
- {
- class Startup
- {
- static void Main()
- {
- int[] numbers = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(x => int.Parse(x))
- .ToArray();
- int k = int.Parse(Console.ReadLine());
- int[] summed = new int[numbers.Length];
- for (int i = 0; i < k; i++)
- {
- IEnumerable<int> firstPart = numbers.Reverse().Take(1);
- IEnumerable<int> lastPart = numbers.Reverse().Skip(1).Reverse();
- int[] newArray = firstPart.Concat(lastPart).ToArray();
- Sum(summed, newArray);
- numbers = newArray;
- }
- Console.WriteLine(string.Join(" ", summed));
- }
- private static void Sum(int[] summed, int[] newArray)
- {
- for (int i = 0; i < summed.Length; i++)
- {
- summed[i] += newArray[i];
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment