Advertisement
Guest User

Untitled

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