Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _02_Rotate_and_Sum
- {
- class Program
- {
- static void Main(string[] args)
- {
- long[] numbers = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
- long rotates = long.Parse(Console.ReadLine());
- //if (rotates >= 1)
- {
- long[] firstRotate = (long[])numbers.Clone();
- long[] sum = new long[firstRotate.Length];
- for (long i = 0; i < rotates; i++)
- {
- firstRotate = RotateArray(firstRotate);
- sum = sum.Zip(firstRotate, (x, y) => x + y).ToArray();
- }
- for (long i = 0; i < sum.Length; i++)
- {
- Console.Write(sum[i] + " ");
- }
- }
- }
- private static long[] RotateArray(long[] firstRotate)
- {
- long[] rotateArray = new long[firstRotate.Length];
- for (int i = 0; i < firstRotate.Length; i++)
- {
- rotateArray[(i + 1) % rotateArray.Length] = firstRotate[i];
- }
- return rotateArray;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement