Guest User

Untitled

a guest
Oct 7th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 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 _00_Exercises
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] number = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14. int n = int.Parse(Console.ReadLine());
  15. int[] rotate = new int[number.Length];
  16. int[] sum = new int[number.Length];
  17.  
  18. for (int i = 0; i < n; i++)
  19. {
  20. for (int j = 1; j < number.Length; j++) // izmestvane na masiva pri vsqka iteraciq
  21. {
  22. rotate[j] = number[j - 1];
  23. }
  24. rotate[0] = number[number.Length - 1];
  25.  
  26. for (int k = 0; k < number.Length; k++) // dobavqne kum sumata pri vsqka iteraciq
  27. {
  28. sum[k] += rotate[k];
  29. }
  30. rotate.CopyTo(number, 0);
  31. }
  32. Console.WriteLine(string.Join(" ", sum));
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment