Cyclically rotate an array by one position


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace OneCompiler
{
	public class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			
			int[] arr = Array.ConvertAll(Console.ReadLine().Split(" "), new Converter<string,int>(StringToInteger));
			
			CyclicalRotate(arr);
			
			for (int i = 0; i < n; i++)
			{
			  Console.Write(arr[i] + " ");
			}
		}
		
		private static int StringToInteger(string s)
		{
		  return int.Parse(s);
		}
		
		private static void CyclicalRotate(int[] arr)
		{
		  int n = arr.Length;
		  
		  if (n == 0 || n == 1)
		  {
		    return;
		  }
		  else
		  {
		    var temp = arr[n - 1];
		    
		    for (int i = n - 1; i > 0; i--)
		    {
		      arr[i] = arr[i - 1];
		    }
		    
		    arr[0] = temp;
		  }
		}
	}
}