#include<iostream>
using namespace std;
long long reverseNumber(long long number,long long result=0) // 给result一个默认值,函数调用时可不向result传参
{
if(number<=9)
{
return result*10+number;
}
int x=number%10;
return reverseNumber(number/10,result*10+x);
}
bool isPalindrome(long long number)
{
return number==reverseNumber(number)?true:false;
}
int main()
{
long long n;
cin>>n;
isPalindrome(n)?cout<<"yes!palindrome"<<endl:cout<<"no"<<endl;
return 0;
}
#include<iostream>
using namespace std;
long long isPalindromeNumber0(long long number)
{
static long long result=0;
if(number==0)
{
long long result0=result;
result=0;
return result0;
}
int temporary=number%10;
result=result*10+temporary;
return isPalindromeNumber0(number/10);
}
bool isPalindromeNumber(long long number)
{
return number==isPalindromeNumber0(number)?true:false;
}
int main()
{
long long n;
cin>>n;
cout<<isPalindromeNumber(n)<<endl;
return 0;
}
登录后提交答案