c**u 发帖数: 2230 | 1 image we have two integers N1, N2.
If we want to get the division, we do : division = (int) N1/N2;
if we want to get the reminder, we do: reminder = N1 % N2;
The interview question is how to get both division and reminder in just one
operation, instead of two? |
t****t 发帖数: 6806 | 2 通常CPU的指令里都是两个一起求的,不过C好象没这说法.好的编译器会自动把这两变成
一个吧.
one
【在 c**u 的大作中提到】 : image we have two integers N1, N2. : If we want to get the division, we do : division = (int) N1/N2; : if we want to get the reminder, we do: reminder = N1 % N2; : The interview question is how to get both division and reminder in just one : operation, instead of two?
|
k****f 发帖数: 3794 | 3 你得定义什么叫做一个operation
是一个汇编指令?一个函数?一个C语句?
one
【在 c**u 的大作中提到】 : image we have two integers N1, N2. : If we want to get the division, we do : division = (int) N1/N2; : if we want to get the reminder, we do: reminder = N1 % N2; : The interview question is how to get both division and reminder in just one : operation, instead of two?
|
c**u 发帖数: 2230 | 4 I think using one "execution" (or one run) is more appropriate. any ideas? |
p***o 发帖数: 1252 | 5 有个叫div/ldiv的非ANSI函数,估计编译器能优化。
【在 t****t 的大作中提到】 : 通常CPU的指令里都是两个一起求的,不过C好象没这说法.好的编译器会自动把这两变成 : 一个吧. : : one
|
c**u 发帖数: 2230 | 6 I think using one "execution" (or one run) is more appropriate. any ideas? |
k****f 发帖数: 3794 | 7 说不清楚就用中文,什么叫做one run
【在 c**u 的大作中提到】 : I think using one "execution" (or one run) is more appropriate. any ideas?
|