osman1997

rotate

Jun 7th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace matrixretakeexamadvanced
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int n = int.Parse(Console.ReadLine());
  12. Queue<int> dataToRotate = new Queue<int>(Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray());
  13.  
  14. int realRotate = n % dataToRotate.Count;
  15.  
  16. for (int i = 0; i < realRotate; i++)
  17. {
  18. int diff = dataToRotate.Dequeue();
  19. dataToRotate.Enqueue(diff);
  20. }
  21. Console.WriteLine(string.Join(" ", dataToRotate));
  22.  
  23.  
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment