PAT B1016.部分A+B(15)

B1016.部分A+B(15)

#include <cstdio>
#include <cstring>

int calc(long long a, long long da) {
     int aa = 0;
     while(a != 0) {
        if(a % 10 == da){
            aa = aa * 10 + da;
        }
        a /= 10;
    }
    return aa;
}
int main() {
    long long a, b, da, db;
    int pa, pb;
    scanf("%lld%lld%lld%lld", &a, &da, &b, &db);
    pa = calc(a, da);
    //printf("%d-----\n", pa);
    pb = calc(b, db);
    //printf("%d-----\n", pb);
    int sum = pa + pb;
    printf("%d\n", sum);
    return 0;
}
posted @ 2019-07-14 15:49  哨音  阅读(188)  评论(0编辑  收藏  举报