PAT 乙级 1016 部分A+B
https://pintia.cn/problem-sets/994805260223102976/problems/994805306310115328
#include <bits/stdc++.h>
using namespace std;
int cal(int x, int Dx) {
int Px = 0;
while (x != 0) {
if (x % 10 == Dx) {
Px = Px * 10 + x % 10;
}
x /= 10;
}
return Px;
}
int main() {
int a, Da, b, Db;
cin >> a >> Da >> b >> Db;
int Pa = cal(a, Da);
int Pb = cal(b, Db);
cout << Pa + Pb;
return 0;
}