Split the array and add the first part to the end | Set 2 | C # program to Split the array and add the first part to the end ; Function to reverse arr [ ] from index start to end ; Function to print an array ; Function to left rotate arr [ ] of size n by k ; Driver code ; Function calling
using System ; class GFG { static void rvereseArray ( int [ ] arr , int start , int end ) { while ( start < end ) { int temp = arr [ start ] ; arr [ start ] = arr [ end ] ; arr [ end ] = temp ; start ++ ; end -- ; } } static void printArray ( int [ ] arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void splitArr ( int [ ] arr , int k , int n ) { rvereseArray ( arr , 0 , n - 1 ) ; rvereseArray ( arr , 0 , n - k - 1 ) ; rvereseArray ( arr , n - k , n - 1 ) ; } public static void Main ( ) { int [ ] arr = { 12 , 10 , 5 , 6 , 52 , 36 } ; int n = arr . Length ; int k = 2 ; splitArr ( arr , k , n ) ; printArray ( arr , n ) ; } }