Advertisement
Qrist

Left Circular Rotation of an Array

Apr 8th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleDifferent
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[] arr = new int [] { 8, 5, 7, 9 };
  10.             Move(arr);         
  11.         }
  12.         static void Move(int[] arr)
  13.         {
  14.             int t = arr.Length;
  15.             int temp = 0;
  16.             for (int i = t-1; i >0; i--)
  17.             {
  18.                 temp = arr[t - 1];
  19.                 arr[t - 1] = arr[i - 1];
  20.                 arr[i - 1] = temp;             
  21.             }
  22.             foreach (int elements in arr)
  23.             {
  24.                 Console.Write(elements + " ");
  25.             }
  26.             Console.WriteLine();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement