mausha

RotateAndSum

Feb 2nd, 2017
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. namespace E_RotateAndSum
  2. {
  3. using System;
  4. using System.Linq;
  5.  
  6. public class RotateSum
  7. {
  8. public static void Main(string[] args)
  9. {
  10. var arrayOfInts = string.Format(Console.ReadLine());
  11. var k = int.Parse(Console.ReadLine());
  12.  
  13. var numbers = arrayOfInts.Split(' ').Select(int.Parse).ToArray();
  14. var result = new int[numbers.Length];
  15. for (int i = 0; i < k; i++)
  16. {
  17. var temp = numbers[numbers.Length - 1];
  18. for (int j = numbers.Length - 1; j > 0; j--)
  19. {
  20. result[j] += numbers[j - 1];
  21. numbers[j] = numbers[j - 1];
  22. }
  23. result[0] += temp;
  24. numbers[0] = temp;
  25. }
  26.  
  27. Console.WriteLine(string.Join(" ", result).ToArray());
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment