Advertisement
cupsamada

palindrom

Dec 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int xb, x10, pb, b, cifmax, aux1, aux2, aux3, cifra, maxim=0, ogl;
  6. cin>>xb;
  7. aux1=xb;
  8. while(aux1!=0)
  9. {
  10. if(aux1%10>maxim)
  11. {
  12. cifmax=aux1%10;
  13. aux1=aux1/10;
  14. }
  15. }
  16. for(b=cifmax+1; b<=10; b++)
  17. {
  18. x10=0;
  19. pb=1;
  20. aux2=xb;
  21. while(aux2)
  22. {
  23. cifra=aux2%10;
  24. x10=x10+cifra*pb;
  25. pb=pb*b;
  26. aux2=aux2/10;
  27. }
  28. ogl=0;
  29. aux3=x10;
  30. while(aux3)
  31. {
  32. ogl=ogl*10+aux3%10;
  33. aux3=aux3/10;
  34. }
  35. if(x10==ogl)
  36. {
  37. cout<<b<<" "<<x10;
  38. break;
  39. }
  40. }
  41. if(x10!=ogl)
  42. {
  43. cout<<0<<" "<<0;
  44. }
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement