Advertisement
bacco

Rotate and Sum

Jun 1st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4.  
  5. namespace wew
  6. {
  7.     class MainClass
  8.     {
  9.         public static void Main(string[] args)
  10.         {
  11.             var nums = Console.ReadLine()
  12.                               .Split()
  13.                               .Select(int.Parse)
  14.                               .ToArray();
  15.  
  16.             var numInterations = int.Parse(Console.ReadLine());
  17.  
  18.             int[] sum = new int[nums.Length];
  19.  
  20.             for (int i = 0; i < numInterations; i++)
  21.             {
  22.                 var last = nums[nums.Length - 1];
  23.  
  24.                 for (int j = nums.Length -1 ; j > 0; j--)
  25.                 {
  26.                     nums[j] = nums[j - 1];
  27.                 }
  28.                 nums[0] = last;
  29.  
  30.                 for (int k = 0; k < nums.Length; k++)
  31.                 {
  32.                     sum[k] += nums[k];
  33.                 }
  34.             }
  35.             Console.WriteLine(string.Join(" ",sum));
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement