denis_andrei10

PALINDROM05

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