Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fin("palindrom.in");
- ofstream fout("palindrom.out");
- int main()
- {
- int xb, aux, b=0, pb=1, x10, i, cifra, og=0;
- fin>>xb;
- aux=xb;
- while(aux)
- {
- if(aux%10>b)
- {
- b=aux%10;
- }
- aux=aux/10;
- }
- b=b+1;
- for(i=b; i<=10; i++)
- {
- pb=1;
- aux=xb;
- x10=0;
- og=0;
- while(aux)
- {
- cifra=aux%10;
- x10=x10+cifra*pb;
- pb=pb*i;
- aux=aux/10;
- }
- aux=x10;
- while(aux)
- {
- og=og*10+aux%10;
- aux=aux/10;
- }
- if(x10==og)
- {
- break;
- }
- }
- fout<<i<<' '<<x10;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment