感觉无论输入什么都不会是回文数......
#include<bits/stdc++.h>
using namespace std;
bool hw(string a){//判断是否回文数
int zjx;//中间项
if(a.length()%2==0){
bool pd;//判断
zjx=a.length()/2-1;//偶数位数字中间项下标就是长度/2-1,如2 4 4 2的中间项设为第一个4
for(int i=0,j=a.length()-1;i<=zjx,j>zjx;i++,j--)
if(a[i]==a[j]) pd=1; else pd=0; return 0;
}
else if(a.length()%2==1){
bool pd;
zjx=(a.length()-1)/2;//奇数位中间项下标,如2 4 5 4 2的中间项设为5
for(int i=0,j=a.length()-1;i<zjx,j>zjx;i++,j--)
if(a[i]==a[j]) pd=1; else pd=0; return 0;
}
return 1;
}
int main(){
string a;
cin>>a;
if(hw(a)) cout<<"你是回文数";
else cout<<"你不是回文数";
return 0;
}