Pergunta de entrevista da empresa Microsoft

reverse an array in place

Respostas da entrevista

Sigiloso

4 de nov. de 2010

be careful with the index of the array

1

Sigiloso

14 de nov. de 2010

//Reverse array in place template void reverse_in_place( T* src_array, size_t count) { if (src_array == NULL) return; if( count <= 1 ) return; //done typename T * front = &src_array[0]; typename T * back = &src_array[count-1]; while (front != back) { std::swap(*front, *back); front++; if(front == back) {break; } ; back--; } }