一美女学霸定义了一种新的乘法,比如123*45=1x4+1x5+2x4+2x5+3x4+3x5,现在给出两个被乘数a,b,输出a*b
Input
两个整数a,b(1<=a,b<=1000000000)
Output
输出a*b
#include <iostream>
using namespace std;
//两种都能通过
int main()
{
int a,b;//第一种
cin>>a>>b;
int x=0;
int y=a;
int jg=0;
while(y)
{
x=y%10;
y=y/10;
int m=0;
int n=b;
while(n)
{
m=n%10;
n=n/10;
jg=jg+x*m;
}
}
cout<<jg;
/*
int a,b;//第二种
cin>>a>>b;
int x=0;
int y=a;
int jg=0;
while(y)
{
x=y%10;
y=y/10;
jg=jg+x;
}
int he=0;
x=0;
y=b;
while(y)
{
x=y%10;
y=y/10;
he=he+x;
}
cout<<jg*he;*/
return 0;
}