Split the array and add the first part to the end | C # program to split array and move first part to end . ; Function to spilt array and move first part to end ; make a temporary array with double the size ; copy array element in to new array twice ; Driver code
using System ; class GFG { public static void SplitAndAdd ( int [ ] A , int length , int rotation ) { int [ ] tmp = new int [ length * 2 ] ; Array . Copy ( A , 0 , tmp , 0 , length ) ; Array . Copy ( A , 0 , tmp , length , length ) ; for ( int i = rotation ; i < rotation + length ; i ++ ) { A [ i - rotation ] = tmp [ i ] ; } } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 12 , 10 , 5 , 6 , 52 , 36 } ; int n = arr . Length ; int position = 2 ; SplitAndAdd ( arr , n , position ) ; for ( int i = 0 ; i < n ; ++ i ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }