-
题目描述:
-
写个算法,对2个小于1000000000的输入,求结果。
特殊乘法举例:123 * 45 = 1*4 +1*5 +2*4 +2*5 +3*4+3*5
-
输入:
-
两个小于1000000000的数
-
输出:
-
输入可能有多组数据,对于每一组数据,输出Input中的两个数按照题目要求的方法进行运算后得到的结果。
-
样例输入:
-
123 45
-
样例输出:
-
54
-
来源:
题目分析:
乘法分配率的水题。
源代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int m, n;
while(scanf("%d%d", &m, &n) != EOF)
{
int a = 0;
int b = 0;
while(m)
{
a += m%10;
m /= 10;
}
while(n)
{
b += n%10;
n /= 10;
}
printf("%d\n", a*b);
}
//system("pause");
return 0;
}
/**************************************************************
Problem: 1083
User: superlc320
Language: C++
Result: Accepted
Time:0 ms
Memory:1020 kb
****************************************************************/