Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace RotateAndSum
- {
- class Program
- {
- public static void Main(string[] args)
- {
- int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int rotations = int.Parse(Console.ReadLine());
- int[] sum = new int[array.Length];
- int[] arrayAfterRotation = new int[array.Length];
- for (int rotation = 1; rotation <= rotations; rotation++)
- {
- for (int currentElement = 0; currentElement < array.Length; currentElement++)
- {
- arrayAfterRotation[currentElement] = array[(array.Length - 1 + currentElement) % array.Length];
- sum[currentElement] += arrayAfterRotation[currentElement];
- }
- array = arrayAfterRotation.ToArray();
- }
- Console.WriteLine(string.Join(" ", sum));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment