Advertisement
SelinD

v89s3ex3

Mar 26th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. void numar(long &n,int c1,int c2)
  5. {
  6. int l=0,v[10],i,ok=1;
  7. while(n>0)
  8. {
  9. v[++l]=n%10;
  10. n=n/10;
  11. }
  12. for(i=l; i>=1; i--)
  13. {
  14. if(v[i]==c1)
  15. {
  16. v[i]=c2;
  17. c2=0;
  18. ok=0;
  19. }
  20. else {
  21. if(ok==0) v[i]=0;
  22. }
  23. }
  24. for(i=l; i>=1; i--)
  25. n=n*10+v[i];
  26. }
  27. int main()
  28. {
  29. long n;
  30. int c1,c2;
  31. cin>>n>>c1>>c2;
  32. numar(n,c1,c2);
  33. cout<<n;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement