ranee

сдвиг массива

Sep 6th, 2022 (edited)
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. int [] array = new int[] { 1, 2, 3, 4 };
  2. Console.Write("Сдвиг влево: ");
  3. int command = Convert.ToInt32(Console.ReadLine());
  4.  
  5. foreach (var arrays in array)
  6. {
  7.     Console.Write($"{arrays} ");
  8. }
  9.  
  10. Console.WriteLine();
  11.  
  12. for (int i = command; i < array.Length; i++)
  13. {
  14.     Console.Write($"{array[i]} ");
  15. }
  16.  
  17. for (int i = 0; i < command; i++)
  18. {
  19.     Console.Write($"{array[i]} ");
  20. }
Advertisement
Add Comment
Please, Sign In to add comment