#include #include #include using namespace std; int str1[100], str2[100], res[100]; int len1, len2, len3; void setData(){ string s1, s2; cin >> s1 >> s2; reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end()); len1 = s1.size(); len2 = s2.size(); int i = 0; for (auto x : s1) str1[i++] = x - ‘0‘; i = 0; for (auto x : s2) str2[i++] = x - ‘0‘; } void example(){ for (int i = 0; i < 10; i++) { str1[i] = str2[i] = i; } len1 = len2 = 10; } void show(){ for (int i = len3; i >= 0; i--) cout << res[i]; } void calc(int len1,int len2){ len3 = max(len1, len2)-1;//相应自始至终都不进位的情形 for (int i = 0; i < len2; i++){ for (int j = 0; j < len1; j++){ res[i + j] += str2[i] * str1[j]; if (res[i + j] >= 10){ len3 = max(len3, i + j + 1); res[i + j + 1] += res[i + j] / 10; res[i + j] %= 10; } } } } int main(){ setData(); //example(); calc(len1,len2); show(); getchar(); getchar(); return 0; } /* 9876543210*9876543210=97546105778997104100 */