Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void numar(long &n,int c1,int c2)
- {
- int l=0,v[10],i,ok=1;
- while(n>0)
- {
- v[++l]=n%10;
- n=n/10;
- }
- for(i=l; i>=1; i--)
- {
- if(v[i]==c1)
- {
- v[i]=c2;
- c2=0;
- ok=0;
- }
- else {
- if(ok==0) v[i]=0;
- }
- }
- for(i=l; i>=1; i--)
- n=n*10+v[i];
- }
- int main()
- {
- long n;
- int c1,c2;
- cin>>n>>c1>>c2;
- numar(n,c1,c2);
- cout<<n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement