不错的读书网站# Livingc*t2011-01-04 08:011 楼Write a function to perform integer division without using either the / or *operators. Find a fast way to do it.
s*t2011-01-04 08:013 楼就是让你把小学二年级用的除法拿程序写出来*【在 c*********t 的大作中提到】: Write a function to perform integer division without using either the / or *: operators. Find a fast way to do it.
c*t2011-01-04 08:014 楼能不能具体的说说?比如 98 除以 5, 程序如何写?谢谢!【在 s*********t 的大作中提到】: 就是让你把小学二年级用的除法拿程序写出来: : *
c*t2011-01-04 08:015 楼用减法int divide(int target, int divisor){int result = 0;while (target - divisor > 0){target -= divisor;++result;}return result;}【在 c*********t 的大作中提到】: 能不能具体的说说?: 比如 98 除以 5, 程序如何写?: 谢谢!
c*p2011-01-04 08:016 楼google booth*【在 c*********t 的大作中提到】: Write a function to perform integer division without using either the / or *: operators. Find a fast way to do it.
c*p2011-01-04 08:017 楼假设A/B:#include int main(){int A, B, tB, tA, Q, R;scanf("%d", &A);scanf("%d", &B);tB = B;if (A{Q = 0;R = A;}else{while(A>tB){tB<<=1;}tB >>= 1;tA = A;Q = 0;while(tB >= B){Q <<= 1;if(tA >= tB){tA -= tB;Q += 1;}tB >>= 1;}R = tA;}printf("%d / %d = %d ... %d\n", A, B, Q, R);return 0;}*【在 c*********t 的大作中提到】: Write a function to perform integer division without using either the / or *: operators. Find a fast way to do it.
c*p2011-01-04 08:018 楼假设A和B都正。这个不是booth算法,但是比一个个减要快。booth带预测,运算量更小一些。可以扩展为支持+和-的运算【在 c****p 的大作中提到】: 假设A/B:: #include : int main(): {: int A, B, tB, tA, Q, R;: scanf("%d", &A);: scanf("%d", &B);: tB = B;: if (A: {