#include using namespace std; int v[100]; int main() { FILE *fin, *fout; int c1,c2,nr,i,k; fin=fopen("nc1c2.in","r"); fout=fopen("nc1c2.out","w"); c1=nr=c2=-1; while(c1!=0||c2!=0||nr!=0) { i=0; fscanf(fin,"%d%d%d",&nr,&c1,&c2); while(nr>0) { v[i]=nr%10; nr/=10; ++i; } for(k=i-1;k>-1;--k) { if(v[k]==c1&&(c2!=0||(c2==0&&k!=i-1))) fprintf(fout,"%d",c2); else fprintf(fout,"%d",v[k]); } fprintf(fout,"\n"); } return 0; }