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