Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int xb, x10, pb, b, aux1, aux2, aux3, cifra, maxim=0, ogl, nb, ok=0;
- cin>>xb;
- aux1=xb;
- while(aux1!=0)
- {
- cifra=aux1%10;
- if(cifra>maxim)
- {
- maxim=cifra;
- }
- aux1=aux1/10;
- }
- for(b=maxim+1; b<=10; b++)
- {
- x10=0;
- pb=1;
- aux2=xb;
- while(aux2)
- {
- cifra=aux2%10;
- x10=x10+cifra*pb;
- pb=pb*b;
- aux2=aux2/10;
- }
- if(maxim+1==b)
- {
- nb=x10;
- }
- ogl=0;
- aux3=x10;
- while(aux3)
- {
- ogl=ogl*10+aux3%10;
- aux3=aux3/10;
- }
- if(x10==ogl)
- {
- ok=1;
- break;
- }
- }
- if(ok==1)
- {
- cout<<b;
- }
- else
- {
- cout<<nb;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement