YavorGrancharov

Rotate_and_Sum

Oct 10th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Rotate_and_Sum
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  12.             int k = int.Parse(Console.ReadLine());
  13.  
  14.             int[] sum = new int[list.Count];
  15.             for (int i = 0; i < k; i++)
  16.             {
  17.                 list.Insert(0, list[list.Count - 1]);
  18.                 list.RemoveAt(list.Count - 1);
  19.  
  20.                 for (int m = 0; m < list.Count; m++)
  21.                 {
  22.                     sum[m] += list[m];
  23.                 }
  24.             }
  25.             Console.WriteLine(string.Join(" ", sum));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment