1) Write a function that receives two integers, positive, and determine the product of them, using the following multiplication method [pending]

0

1) Write a function that receives two integers, positive, and determine the product of them, using the following multiplication method.

a. Divide, successively, the first number by 2, until 1 is obtained as a quotient; B. Simultaneously, fold the second number in succession; W. Add the numbers in the second column that have an odd number in the first column. The total obtained is the product sought.     Ex.: 9 * 6 9 6 4 12 2 24 1 48

    
asked by anonymous 03.04.2017 / 01:55

1 answer

0

I believe that the a and b parts are something like this

int multiplicacao(unsigned int x, unsigned int y){
   do{
      x = x/2;
      y = y * 2
   } while(x!=1);    
}

unsigned int ensures that they are positive

    
19.04.2017 / 16:28