#include<iostream> #include<string> using namespace std; int main() { string num1, num2; int arr1[100], arr2[100]; int l1, l2, res; while (cin >> num1 >> num2) { l1 = num1.length(); l2 = num2.length(); for (int i = 0; i < l1; i++) { arr1[i] = num1[i] - '0'; } for (int i = 0; i < l2; i++) { arr2[i] = num2[i] - '0'; } res = 0; for (int i = 0; i < l1; i++) { for (int j = 0; j < l2; j++) { res += arr1[i] * arr2[j]; } } printf("%d\n", res); } }
简单题,其实可以不用两层循环,直接就是两个数的数字和之积