Varianta 86 / Subiectul 3 / Problema 3 |
#include<iostream.h> long numar(long x, int c1,int c2) { long r=0; while(x) { if(x%10==c1) r=r*10+c2; else r=r*10+x%10; x=x/10; } while(r) { x=x*10+r%10; r=r/10; } return x; } int rec(int x, int c1, int c2) { if(x==0) return 0; else if(x%10==c1) return rec(x/10,c1,c2)*10+c2; else return rec(x/10,c1,c2)*10+x%10; } void main() { long x; cin>>x; cout<<rec(x,4,7); } |