Advertisement
SelinD

v86s3e3

Mar 12th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int numar(int n,int c1,int c2)
  5. {
  6. int p=1,rez=0,c;
  7. while(n!=0)
  8. {
  9. c=n%10;
  10. if(c==c1)
  11. rez=rez+p*c2;
  12. else
  13. rez=rez+p*c;
  14. p=p*10;
  15. n=n/10;
  16. }
  17. return rez;
  18. }
  19. int main()
  20. {
  21. int n,c1,c2;
  22. cin>>n>>c1>>c2;
  23. cout<<numar(n,c1,c2);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement