水题一只,做一个判断就ok了.
#include "iostream"
#include "string"
using namespace std;
int main()
{
long num1,num2;
long bit1,bit2;
long temp1,temp2;
long result1 = 0,result2 = 0;
cin>>num1>>bit1>>num2>>bit2;
//num1 = 3862767; bit1 = 6; num2 = 13530293; bit2 = 3;
while(num1!=0)
{
temp1 = num1%10;
if(temp1 == bit1)
result1 = (result1*10) + temp1;
num1/=10;
}
while(num2!=0)
{
temp2 = num2%10;
if(temp2 == bit2)
result2 = (result2*10) + temp2;
num2/=10;
}
cout<<result1+result2<<endl;
return 0;
}