C++编程第30题

//一个5位数,判断它是不是回文数。
//即12321是回文数,个位与万位相同,十位与千位相同。


#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,e,x;
    cout<<"Please input the number ";
    cin>>x;
    a=x/10000;
    b=(x/1000)%10;
    c=(x/100)%10;
    d=(x/10)%10;
    e=x%10;
    if(a==e&&b==d){
        cout<<x<<"是回文序列"<<endl;
    }else{
        cout<<x<<"不是回文序列"<<endl;
    }

    cout << "Hello world!" << endl;
    return 0;
}


运行结果为:

你可能感兴趣的:(编程,C++)