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 r=0;
- int p=1;
- while(n)
- {
- if(n%10==c1)
- {
- r=r+p*c2;
- p=p*10;
- n=n/10;
- } else
- {
- r=r+p*(n%10);
- p=p*10;
- n=n/10;
- }
- }
- return r;
- }
- int main()
- {
- cout<<numar(14944, 4, 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement