【清华大学考研机试题】特殊乘法

版权声明:假装有个原创声明……虽然少许博文不属于完全原创,但也是自己辛辛苦苦总结的,转载请注明出处,感谢! https://blog.csdn.net/m0_37454852/article/details/88360380

原题链接

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std;

int main()
{
    char A[20], B[20];
    while(scanf("%s %s", A, B) != EOF)
    {
        getchar();
        int lenA = strlen(A);
        int lenB = strlen(B);
        int sumA = 0, sumB = 0;
        for(int i=0; i<lenA; i++) sumA += A[i] - '0';
        for(int i=0; i<lenB; i++) sumB += B[i] - '0';
        printf("%d\n", sumA*sumB);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_37454852/article/details/88360380