You are viewing a single comment's thread. Return to all comments →
This is my C# sharp code.
string[] s1 = Console.ReadLine().Split(' '); int n = int.Parse(s1[0]); int k = int.Parse(s1[1]); string[] s = Console.ReadLine().Split(' '); int[] array = new int[n]; ////pre-rotation of array method: //-----------------------------------Right rotation //for (int i = 0; i < n; i++) //{ // array[(i + k) % n] = int.Parse(s[i]); //} //------------------------------------Left rotation for (int i = 0; i < n; i++) { array[(i + (n-k)) % n] = int.Parse(s[i]); } for (int i = 0; i < n; i++) { Console.WriteLine(array[i]+" "); }
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 →
This is my C# sharp code.