Pseudocode
Code:
if(!(array_size%4)) /* ensure we can shift 4 items on each run */
store array[array_size -3] in temp_1
store array[array_size -2] in temp_2
store array[array_size -1] in temp_3
store array[array_size] in temp_4
while(array[index])
switch array[index] with temp_1
switch array[index+1] with temp_2
switch array[index+2] with temp_3
switch array[index+3] with temp_4
index+=4
And you couldn't think of that yourself ?
By the way, what is
old C++ ?? you've got the STL right there, why not use it??