Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n, c1, c2, x=0, cif, z=1;
cin >> n >> c1 >> c2;
int copie=n;
while (n)
{
cif=n%10;
if (cif==c1) x=x+z*c2;
else x=x+z*cif;
z*=10;
n/=10;
}
if (copie==0 && c1==0) x=c2;
cout << x;
}
Explicație: