原题链接
总结:string的运用
#include <iostream>
using namespace std;
int main()
{
string A,B;int DA,DB;int PA = 0,PB = 0;cin>>A>>DA>>B>>DB;for(int i=0;i<A.length();i++){
if(DA == (A[i] - '0')){
PA = PA*10 +DA;}}for(int i=0;i<B.length();i++){
if(DB == (B[i] - '0')){
PB = PB*10 +DB;}}cout<<PA + PB;return 0;
}