From 8c60af6f471e021638f29dcac5c7243506f872b2 Mon Sep 17 00:00:00 2001 From: Rozza <59175124+rozza7@users.noreply.github.com> Date: Sat, 29 Oct 2022 00:50:54 +0530 Subject: [PATCH] Rotate Array by 1 place left Created by Rojarani --- 2022-Oct/13 Oct 2022/rojarani_akkisetty.cs | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 2022-Oct/13 Oct 2022/rojarani_akkisetty.cs diff --git a/2022-Oct/13 Oct 2022/rojarani_akkisetty.cs b/2022-Oct/13 Oct 2022/rojarani_akkisetty.cs new file mode 100644 index 00000000..7dd7ab52 --- /dev/null +++ b/2022-Oct/13 Oct 2022/rojarani_akkisetty.cs @@ -0,0 +1,36 @@ +/// C# Program to rotate the array to left by 1 place + +using System; + +namespace Program +{ + public class ArrayRotate + { + public static void Main(String[] args) + { + int n = Convert.ToInt16(Console.ReadLine()); + + int[] arr = new int[n]; + for (int i = 0; i < n; i++) + arr[i] = Convert.ToInt16(Console.ReadLine()); + + // Storing the first element of array arr[] + // into temp + int temp = arr[0]; + + // Storing the n - 1 elements of + // array arr[] to the front of arr[] + for (int i = 0; i < n-1; i++) + arr[i] = arr[i+1]; + + //Storing temp to end of arr[] + arr[n-1]=temp; + + //Print the elements of an array + for (int i = 0; i < n; i++) + Console.Write(arr[i].ToString() + " "); + + } + } +} +