```cpp
//使用visual studio2019
#include<iostream>
using namespace std;
int main()
{
int multipy(int m, int n);
int a, b;
cout << "请输入两个整数\n";
cin >> a >> b;
cout << multipy(a, b);
}
int multipy(int m, int n)
{
int quo[32];
int j = 0;
int sum=0;
while (n > 0)
{
quo[j] = n;
n = n / 2;
j += 1;
}
quo[j] = 0;
int temp = quo[j];
for (int i = j; i>=1; i--)
{
if (quo[i - 1] % 2 == 0)
{
sum = 2 * temp; temp = sum;
}
else
{
sum = 2 * temp + m; temp = sum;
}
}
return sum;
}
测试: