http://ac.jobdu.com/problem.php?pid=1083
题目描述:
写个算法,对2个小于1000000000的输入,求结果。
特殊乘法举例:123 * 45 = 1*4 +1*5 +2*4 +2*5 +3*4+3*5
//题目1083:特殊乘法
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char A[10], B[10];
ifstream cin("data.txt");
while (cin >> A >> B)
{
int i, j, sum = 0, temp1, temp2;
for (i = 0; A[i] != '\0'; i++)
for (j = 0; B[j] != '\0'; j++)
{
temp1 = A[i] - '0';
temp2 = B[j] - '0';
sum += temp1 * temp2;
}
cout << sum << endl;
}
system("pause");
return 0;
}