题解 | #特殊乘法#
特殊乘法
https://www.nowcoder.com/practice/a5edebf0622045468436c74c3a34240f
#include "stdio.h" using namespace std; int main(){ int num1,num2; while (scanf("%d%d",&num1,&num2)!=EOF) { int count1=0,count2=0;//count1为num1的位数,count2为num2的位数 int array1[12],array2[12]; while (num1 > 0) { array1[count1] = num1%10; num1 = num1/10; ++count1; } while (num2 > 0) { array2[count2] = num2%10; num2 = num2/10; ++count2; } int sum = 0; for(int i = 0;i<count1;++i){ for(int j = 0;j<count2;++j){ sum = sum + array1[i]*array2[j]; } } printf("%d\n",sum); } }