Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _02.Rotate_and_Sum
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split();
- long rotation = long.Parse(Console.ReadLine());
- int[] nums = ParseNums(input);
- long[] sum = new long[input.Length];
- MakeRotation(nums, sum, rotation);
- Console.WriteLine(string.Join(" ", sum));
- }
- private static void MakeRotation(int[] nums, long[] sum, long rotation)
- {
- for (int i = 0; i < rotation; i++)
- {
- int last = nums[nums.Length - 1];
- for (int j = nums.Length - 1 ; j >= 0; j++)
- {
- nums[j] = nums[j - 1];
- }
- nums[0] = last;
- for (int a = 0; a < nums.Length; a++)
- {
- sum[a] += nums[a];
- }
- }
- }
- private static int[] ParseNums(string[] input)
- {
- int[] nums = new int[input.Length];
- for (int i = 0; i < input.Length; i++)
- {
- nums[i] = int.Parse(input[i]);
- }
- return nums;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement