Pregunta de entrevista de Pocket Gems

Round a floating point number to the nearest integer. Do not use any helper functions.

Respuesta de la entrevista

Anónimo

21 feb 2012

int round(float input) { int x = ( input > 0 ) ? (input + 0.5):(input - 0.5) ; return x ; }

1