You are viewing a single comment's thread. Return to all comments →
It is not the best solution but it requires only one array:
static void Main(String[] args) { string[] read = Console.ReadLine().Split(' '); int n = int.Parse(read[0]); int d = int.Parse(read[1]); int[] array = new int[n]; array = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse); for(int q=0;q<d;q++) for(int i=0;i<n-1;i++) { swap(array, i,i+1); } for(int y=0;y<n;y++) Console.Write(array[y] + " "); Console.WriteLine(); } static void swap(int[] input, int indexA, int indexB) { int tmpA = input[indexA]; int tmpB = input[indexB]; input[indexA] = tmpB; input[indexB] = tmpA; }
Seems like cookies are disabled on this browser, please enable them to open this website
Left Rotation
You are viewing a single comment's thread. Return to all comments →
It is not the best solution but it requires only one array: