判断输入的整数是否回文,输入的数据在10-1000以内
"回文数"是一种数字.如:98789, 这个数字正读是98789,倒读也是98789,正读倒读一样,所以这个数字就是回文数。
输入格式:
10-1000的数字。
输出格式:
true或者false
输入样例:
121
133
输出样例:
true
false
#include <iostream>
#include<string>
using namespace std;
bool s(string a){
int sz=a.length();
for(int i=0;i<sz-1;i++)
if(a[i]!=a[sz-i-1])return false;
return true;
}
int main(){
string a;
while(1){
getline(cin,a);
if(s(a))cout<<"ture"<<endl;
else cout<<"false"<<endl;
}
}