Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int s1(int n)
- {
- int c=0;
- while (n)
- {
- n=n/10;
- c++;
- }
- return c;
- }
- int s2(int k)
- {
- int q,i,nr2,nou,cif,zece;
- cout<<"q= ";cin>>q;
- int cop;
- cop=q;
- while (cop)
- for (i=1;i<=s1(q);i++)
- {
- zece=pow(10,i);
- if (cop%10==k)
- {
- nr2=cop%zece;
- cop=cop/zece;
- cop=cop*10+cop%10;
- cop=cop*zece+nr2;
- nou=cop;
- }
- cop=cop/10;
- }
- cout<<nou;
- }
- int main()
- {
- s2(2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement