Advertisement
NonaG

RotateAndSum

Feb 2nd, 2017
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 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 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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement