/* Puzzle C38 -- shift array elements N positions left; */ /* the last N elements get 0; */ /* the first N elements are discarded */ void shiftLeftNArray( int arr[], int size, int shift ) { int j; if ( shift<0 ) return; if ( shift>=size ) { for ( j=0; j<size; j++ ) arr[j] = 0; return; } for ( j=0; j<size-shift; j++ ) arr[j] = arr[j+shift]; for ( j=size-shift; j<size; j++ ) arr[j] = 0; }