Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _02.RotateAndSum
- {
- public class StartUp
- {
- public static void Main()
- {
- long[] numbers = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToArray();
- long k = long.Parse(Console.ReadLine());
- long[] rotatedArr = new long[numbers.Length];
- long[] sum = new long[numbers.Length];
- for (int i = 0; i < k; i++)
- {
- rotatedArr[0] = numbers[numbers.Length - 1];
- for (int j = 0, index = 1; j < numbers.Length - 1; j++, index++)
- {
- rotatedArr[index] = numbers[j];
- }
- for (int j = 0; j < numbers.Length; j++)
- {
- sum[j] += rotatedArr[j];
- }
- rotatedArr.CopyTo(numbers, 0);
- }
- Console.WriteLine(string.Join(" ",sum));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment