GerganaTsirkova

Rotate and sum

Jan 7th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  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 Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. int k = int.Parse(Console.ReadLine());
  15. int[] sumArray = new int[arr.Length];
  16. int[] myNewArray = new int[arr.Length];
  17. for (int j = 0; j < k; j++)
  18. {
  19. for (int i = 0; i < arr.Length-1; i++)
  20. {
  21. myNewArray[i] = arr[(i + 1) % arr.Length];
  22. sumArray[i] += myNewArray[i];
  23. }
  24. }
  25.  
  26. Console.WriteLine(string.Join(" ", sumArray));
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment