#include <iostream>
using namespace std;
// multi number
int multi(int a,int b);
int main()
{
int a,b,i = 0;
while(i<100)
{
a = rand()%100,b = rand()%100;
cout<<"a="<<a<<" ,b="<<b<<" ,a*b="<<multi(a,b)<<endl;
i++;
}
system("pause");
return 0;
}
// multi number
int multi(int a,int b)
{
bool fushu = false;
if(a <= 0)
{
if( a==0 )
return 0;
a = -a;
fushu = !fushu ;
}
else if(b <= 0)
{
if( b==0 )
return 0;
b = - b;
fushu = !fushu ;
}
int result = 0 ;
while( a >= 1 )
{
if( a%2 != 0 )
result = result + b ;
a = a/2;
b = b*2;
}
if(fushu)
result = - result;
return result;
}