@chawuciren
2019-09-08T13:19:50.000000Z
字数 224
阅读 509
CINTA
/*
* Input: two integer(a and b)
* Output: a*b
* Method: iterative method
*/
int Multiplication(int a,int b){
int res=0;
do{
int p=b&1;//存放这一位
b=b>>1;//b右移一位,下一次迭代就可以取下一位
if(p==1)
res+=a;
a<<=1;
}while(b!=0);
return res;
}