#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int Is_Palindrome_Num(char* num)
{
int len=strlen(num);
for(int i=0;i<len/2;i++)
{
if(num[i]!=num[len-i-1])
{
return 0;
}
}
return 1;
}
int IsDB_Palindrome_Num(int num)
{
char strNum[100];
memset(strNum,0,sizeof(strNum));
sprintf(strNum,"%d",num);
int len=strlen(strNum);
int count=0;
int temp=num;
for(int k=2;k<=10;k++)
{
for(int i=0;;i++)
{
strNum[i]=temp%k+'0';
temp=temp/k;
if(0==temp)
{
break;
}
}
temp=num;
if(Is_Palindrome_Num(strNum))
{
count++;
if(2==count)
{
break;
}
}
memset(strNum,0,sizeof(strNum));
}
return count;
}
int main()
{
int num;
cin>>num;
num++;
while(1)
{
if(IsDB_Palindrome_Num(num)>=2)
{
cout<<num<<endl;
break;
}
num++;
}
return 0;
}
7-1-4 双基回文数
最新推荐文章于 2021-11-14 16:59:12 发布