Title Description
Write algorithm, the input to one billion two small, find results. Special multiplication Example: 1 123 * 45 * 4 + 1 = 5 + 2 * 4 + 2 * 3 * 4 * 5 + 3 + 5 *
Entry
Two less than the number of 1,000,000,000
Export
Multiple sets of data may be input, for each set of data, the number of output two Input calculation result obtained in the method according to the requirements of the subject.
Sample input
24 65 42 66666 3 67
Sample Output
66 180 39
#include <stdio.h>
#include <string.h>
int main()
{
int a[12],b[12];
char str1[12],str2[12];
while(scanf("%s %s",str1,str2)!=EOF) //输入两个字符
{
int sum=0;
for(int i=0; i<strlen(str1); i++) //将字符型数组转换为int型数组
{
a[i]=str1[i];
a[i]-=48;
}
for(int i=0; i<strlen(str2); i++)
{
b[i]=str2[i];
b[i]-=48;
}
for(int i=0; i<strlen(str1); i++) //运算特殊乘法
for(int j=0; j<strlen(str2); j++)
{
sum+=a[i]*b[j];
}
printf("%d\n",sum); //输出结果
}
return 0;
}