SHARE
TWEET

RotateAndSum

NonaG Feb 2nd, 2017 194 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace RotateAndSum
  8. {
  9.     class RotateAndSum
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14.             int rotations = int.Parse(Console.ReadLine());
  15.             int[] sum = new int[array.Length];
  16.             for (int i = 0; i < rotations; i++)
  17.             {
  18.                 var last = array[array.Length - 1];
  19.                 for (int j = array.Length - 1; j > 0; j--)
  20.                 {
  21.                     array[j] = array[j - 1];
  22.                 }
  23.                 array[0] = last;
  24.                 for (int k = 0; k < array.Length; k++)
  25.                 {
  26.                     sum[k] += array[k];
  27.                 }
  28.             }
  29.             Console.WriteLine(string.Join(" ", sum));
  30.         }
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top