不用太麻烦,直接整个字符串存起来就好了

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    long long res = 0;
    for (int i = 0; i < s1.size(); ++i)
        for (int j = 0; j < s2.size(); ++j)
            res += (s1[i] - '0') * (s2[j] - '0');
    cout << res << endl;
    return 0;
}