typedef long long_int;
int Divide(int dend, int dsor)
{
long_int dividend = dend;
long_int divisor = dsor;
int quotient = 0;
bool negative = false;
if (dividend < 0)
{
negative = true;
dividend = -dividend;
}
if (divisor < 0)
{
negative = !negative;
divisor = -divisor;
}
while(dividend >= divisor)
{
long_int addition = divisor;
int cur_quotient = 1;
while(dividend >= (addition + addition))
{
addition += addition;
cur_quotient <<= 1;
}
quotient += cur_quotient;
dividend -= addition;
}
if (negative) quotient = -quotient;
return quotient;
}
#include <stdio.h>
int main(int argc, char** argv)
{
int dividend = 2147483647;
int divisor = 3;
printf("%d\n", Divide(dividend,divisor));
return 0;
}