你不知道的事

1.不开辟空间 倒序数组

int i = 0;

for(int j = 0; j < arr.count; j++) {

long s = arr.count-1-j;

NSObject *str = arr[i];

NSObject *str1 = arr[s];

if (i == s || s-i < 1)break;

arr[i] = str1;

arr[s] = str;

i++;

}

2.round, roundf, roundl, lround, lroundf, lroundl, llround, llroundf, llroundl

round(+2.3) = +2.0  round(+2.5) = +3.0  round(+2.7) = +3.0

round(-2.3) = -2.0  round(-2.5) = -3.0  round(-2.7) = -3.0

round(-0.0) = -0.0

round(-Inf) = -inf

lround(+2.3) = 2  lround(+2.5) = 3  lround(+2.7) = 3

lround(-2.3) = -2  lround(-2.5) = -3  lround(-2.7) = -3

lround(-0.0) = 0

lround(-Inf) = -9223372036854775808

lround(LONG_MAX+1.5) = -9223372036854775808

你可能感兴趣的:(你不知道的事)